Hi,
We are using UltraWinGrid to display data to the user, what we are doing here is we are creating the columns dynamically and hence even if we add a column represneting date time value the column style of it is Deafult. We can't change it to DateTime as it throws error as 'Cant set the datatype property for unbound column'. But when the data is displayed we get an Calendar for filetering the rows. Now when I select a valid date from the calendar and try to filter the rows I am getting zero results,even if the rows contain the date the filtering doesnt works here.
I tried using FilterCellValueChanged event and tried to add FilterConditions in which I tried adding instance of the class derived from FilterCondition. In the class I overrirded the MeetsCriteria method but it never got hit. I have even tried with the BeforeRowFilterChanged event but nothing worked for me.
Also in filter cell whenever I tried to maually enter the filtering value of Date the year is getting defaulted to 2002, if I only enter 8 then it becomes 2008. Is this a expected behaviour. ??
Please provide some inputs to solve this error.
Regards
Enzo
Hi Enzo,
Enzo said:we are creating the columns dynamically
What kind of data source are you using for your grid? How are you creating the columns?
Enzo said:We can't change it to DateTime as it throws error as 'Cant set the datatype property for unbound column'.
That doesn't make sense. Exactly the opposite is true. You can change the data type of an unbound column. What you can't do is change the datatype of a bound column.
Q .What kind of data source are you using for your grid?
Answer .We are assigning a dataset as a datasource to the grid.
Q. How are you creating the columns?
Answer. The columns are created on the basis of data set columns that we get from Db, we assign name to them and we retrieve the columns as per the names. But this doesnt have to do with the data type. As i told the Datatype is default and if i try to assign it gives 'DataType can only be set for an unbound column' error. we create a temporary collection of UltraGridColumn and then add it into UltraGridBand for the grid.
I'm really not clear on what you are doing to create the column. If you are setting a DataSet as the grid's DataSource, then the grid will automatically create columns based on that data source and get the data types of those columns from the data source fields. These are bound columns and you will not be able to change the data types on these.
You cannot create a column outside the grid and add it into the grid. The only way to add an unbound column to the grid is using the Band.Columns.Add method.
If you are creating column objects and adding them to the band somehow, then you are probably using methods that are intended for internal use by the grid and will not work.
I have the same problem...
My grid is binded to a generic list of object (VB.NET) and the filter row works fine for all columns (even for nullable fields) but not for columns binded to a date (or datetime) datatype. The filtreRow recognize the datatype of the column and display a calendar (as it should) but, if I try to set the filter to an existing date (the date exist in one or many datarow) and choose the "=" operator, the grid doesn't return any row. (but it should)
One thing I've noticed, I've set the style of the date columns to "Date" style like that:
e.Layout.Bands(0).Columns("MyColumn1").Style = ColumnStyle.Date
so the grid doesn't display the "Time" part of the date (01/01/2009 08:25:53:00) but the filter seems to search for a date who exactly match with the date choosen in the calendar. The filter give a date like: 01/01/2009 00:00:00:00.
There is a way to set filters for date columns so the don't try to match a complete datetime field but just the date part ?
I am trying this code but It was not filtering can You tell me in which event I can add the above code am trying in ultrawingrid_intializelayout
InitializeLayout is an excellent place to do this. If it's not working, you must be clearing the filters after you set them. Maybe you are loading a Layout which is blowing them away. Or maybe the code to set them is never getting hit.