Hi,
I have an UltraGrid in virtual mode. Each column has its defined data type (int, double, DateTime, bool, string and etc.) and format. I need to have a fixed row at the top of the grid. This fixed row is used as the filter row and user can enter filter expressions. I have my an external data source and I do filtering and sorting to the data in this external data source. My UltraGrid is used to display data only. There may be different ways to implement this. The two apparent ways to do this is:
I tried to use the first method, but was not able to change the data type of filter row cells. I cannot enter a filter expression into a filter cell if its data type is not string. I haven't tried the second way.
Any suggestion and help is greatly appreciated!
Best regards,Shaolin
I changed the data type of all UltraDataColumn's to typeof(object) and it worked fine. I have a follow up question. Will this change cause any performance issue?
Thanks,Shaolin
Hi Shaolin,
Changing the data type of UltraDataColumn to “Object” type might not cause any performance issues but it might affect the Grid filtering and sorting functionality. If you are not implementing any sorting or filtering for your Grid columns then changing the column type to “Object” might not hinder the Grid's performance.
Please let me know if I may be of further assistance.
Sincerely,Sahaja KokkalagaddaAssociate Software Developer
Hi Sahaja,
I have some new problems.
First, I need to show checkbox on non-editable columns of which the data type is Boolean:
if (realType == typeof(bool)) { var checkEditor = new CheckEditor { CheckAlign = ContentAlignment.MiddleCenter }; ultraGridColumn.Editor = checkEditor; }
Secondly, There is no editor showing up for any column in editable mode because the data type is of object.
Your help is greatly appreciated!
Best Regards,Shaolin
Hi Team,
Can someone from support take a look at this please?
I'm not sure I understand your question. You seem to be asking how to make a column show as a checkbox, but then you have code assigning a CheckEditor to the column, which answers the question. So what are you asking?
You can make a column show a checkbox by assigning an editor like you are doing, or you could just set the column's Style property to Checkbox.
Object is not a great DataType to use for several reasons, but one of those reasons is that the grid cannot detect which editor to use. But again, you can assign an Editor, EditorComponent, or set the column's Style. This may not work in all cases. Some editors will not be able to function if the DataType of the column is object.
Hi Mike,
Thanks so much for your answer!
I am attaching a screen shot from my evaluation demo application. It is an UltraGrid with virtual mode. We have our customized filter (first row) and summary (second row) rows (fixed on top). User can type a filter expression into a cell on the filter row and the filtering expression can be comlicated. All the cells on the filter row have to a text editor. We need to display check-boxes for a column of boolean data type, whether they are editable or not.
There is a dilemma with grid cell value data types. All cells of the filter row need string data type but columns need specific data types for their cell values: bool, int, double, datetime, string and etc.
Is anyone looking at my questions?
I'm afraid I am still not sure what you are asking.
You cannot change the DataType of a cell or a bound column.
The grid has built-in filtering capability, but it seems like you are trying to use your own custom filtering with a row in the data source that can accept values that are not of the same data type as the rest of the cells in that column. There is no way to do that, either. Which means you would have to set every field in your grid to a data type like string or object that can accept any value of any type. This will cause all sorts of problems, though. Many of the editors will not work with a string or an object. So I don't think any of these approaches are a viable solution.
Why can't you use the FilterRow in the grid? What kind of functionality do you need that the filter row does not already provide?
If you really need to handle the filtering yourself in some complex way that the existing filter row cannot do, then I think the best way to do that might be to implement your filtering UI in some other control or controls outside of the grid.
For example, you could create a second grid that has a single row and position it on top of the "real" grid. The second grid could be bound to a data source that has the same column names but is bound to a table where every field is an object. You would then have to write code to synchronize the two grids scrolling and filtering, etc.
Frankly, though, I recommend that you reconsider using the built-in filtering if you can. What you are trying to do is going to be extremely complex and difficult any way you look at it.
Thanks so much for your explanation!
My filter row is very simple. All cells on the filter row can only have a text editor and it will take any text. Once the text in the editor is changed, the event handler will parse the text and validate whether the text is a valid filtering expression for the column. We do have our own filtering logic applied to the data source, so we only use filter row to allow user to enter an filter expression. I noticed that the cell of on the built-in filter row have buttons and a drop-down combo-box, which we do not need. Do you have any sample to do this?
There are properties on the Override to remove the dropdown and buttons from the filter cells:
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { var layout = e.Layout; var band = layout.Bands[0]; var ov = layout.Override; ov.AllowRowFiltering = DefaultableBoolean.True; ov.FilterUIType = FilterUIType.FilterRow; // Remove the dropdown button ov.FilterOperandStyle = FilterOperandStyle.Edit; // Remove the operator button ov.FilterOperatorLocation = FilterOperatorLocation.Hidden; // Remove the clear button. ov.FilterClearButtonLocation = FilterClearButtonLocation.Hidden; // Tell the grid not to do anything with the filters ov.RowFilterAction = RowFilterAction.None; }
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { var layout = e.Layout; var band = layout.Bands[0]; var ov = layout.Override;
ov.AllowRowFiltering = DefaultableBoolean.True; ov.FilterUIType = FilterUIType.FilterRow; // Remove the dropdown button ov.FilterOperandStyle = FilterOperandStyle.Edit;
// Remove the operator button ov.FilterOperatorLocation = FilterOperatorLocation.Hidden;
// Remove the clear button. ov.FilterClearButtonLocation = FilterClearButtonLocation.Hidden;
// Tell the grid not to do anything with the filters ov.RowFilterAction = RowFilterAction.None; }
But I'm not sure this is a viable solution. The grid is still going to try to take the text that the user types into the cell and apply a filter. So it might try to cast the value into the correct data type and build the FilterConditions, which you really don't want. I might be wrong... maybe the FilterConditions will just get created with a string and you can then handle the FilterRow event to examine the filter conditions and do your own filtering. It's worth a try, I guess.
Thanks so much!
I will give it a try.