How to clear data only from ultragrid..Keep other settings intact as they dont change and i dont want to apply the definition again and again..
Also, what exactly does sortedcolumns.clear do? can you give a specific example?
Thanks for your help
Hi,
What other settings are you referring to? You mean things like the column widths and positions?
The only way to clear the data from the grid is to remove it from the data source. So you would have to remove all of the rows from your data source. How you do that depends on what kind of DataSource you are using.
Another option would be to use the Save method on the grid's DisplayLayout, then set the grid's DataSource to null. This will destroy the layout, of course, but then you could re-load the layout from the save.
Sandeep D said:Also, what exactly does sortedcolumns.clear do? can you give a specific example?
When you sort a column in the grid (usually by clicking on the column header), the column is added to the SortedColumns collection. Clearing the collection will remove all columns from the collection and thus clear the sort indicator on every column in the band. Sorting is also tied to grouping. So if you are using OutlookGroupBy, the grouping would be cleared, as well.
Thanks for the reply!
I am binding the datagrid to an empty object instead of null and it now preserves the layout. Earlier , when i was putting the datasource as null then the layout was lost and even hidden columns were displayed.
While we are on groupby, can you advise how to do the following:
Group on a column when binding to datagrid. (i know this part)
and then within each group order by particular field (such as a date field) --> need help with this part
Thanks
Hi Sandeep,
What are you trying to sort - the GroupByRows, or the data under the GroupByRows?
The latter is pretty easy - you just have to add another column to the SortedColumns collection of the band.
The former is more complicated because in order to group, the grid sorts the data first and then groups the rows with the same values. So you would have to change the sort order of the column itself, probably by using a SortComparer.
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { UltraGridLayout layout = e.Layout; UltraGridBand band = layout.Bands[0]; layout.ViewStyleBand = ViewStyleBand.OutlookGroupBy; band.SortedColumns.Add("Int32 1", false, true); band.SortedColumns.Add("DateTime 1", false, false); }
The second option pls which is easier..i just ned to order within the group and not the group column itself
I'd be happy to give you some sample code, but which one are you trying to do?
Either way, it must be done after the grid is bound.
Thanks.Can you provide a code sample..Also, i do this before binding data to the grid or after binding data.