Hi Team,
I am currently using a UltraGrid which bind to UltraDataSource. I want to apply sort function on the grid.
1. I tried grid.SortedColumns.Add(XXX). This applied the sort on Grid. However, I found out this won't effect the data on UltraDataSouce which somehow I need to sorted as well.
2. Then I tried to sort on the ultraDataSource. I sorted the tag of rows as well. However, it doesn't apply any sort on the grid. Am I missing anything? Do I need to sort on the UltraDataSource.Rows rather than Tag? How can I get the businees object behind and sort on the them?
List<Row> rows_= mainUltraDataSource.Rows.Tag as List<Row>;
rows_.Sort(XXX)
Thanks,
Xin
yuxin0717 said:I presume ultraDataSource dosen't support group by either?
That is correct, it does not support OutlookGroupBy.
yuxin0717 said:So we somehow need to remove/insert rows?
If you are loading on demand, then I think you can simply clear any cached information in the UltraDataSource and tell it to refresh itself from the "real data. So you would sort your data and then call ResetCachedValues on the UltraDataSource which will throw away any accumulated data and re-load as needed.
Hi Mike,
Thanks for your suggestion!
About yout command on LoadOnDemand, that's exactly the reason why I need to sort on data source level, because at the time I sort, I haven't load all data yet. And after I sort, I may need to insert more rows according to my current structure!
I presume ultraDataSource dosen't support group by either? So we somehow need to remove/insert rows?
Hi Xin,
yuxin0717 said:However, about your conern about grid will get a notification every time a row is removed or added, Can we use _grd.BeginUpdate() to avoid this?
Using BeginUpdate/EndUpdate is a good idea.
You can also use SuspendRowSynchronization and RemoveRowSynchronization to improve performance.These should be used inside the BeginUpdate/EndUpdate block.
yuxin0717 said:btw, Is there any reason that ultradDataSource doesn't support sort? It will be great that it supports sort as other data source.
It's never been a big feature request. Probably because the grid already has sorting built-in.
By the way... if you are using UltraDataSource for it's LoadOnDemand functionality, then sorting the data would require loading all of the data into memory, anyway, thus defeating any benefits from loading on demand.
The reason I need to use UltraDataSource is because I need it's Load On Demand function to hlep on performance. I am current using removing and re-inserting the rows as alternertive way. It works fine. However, about your conern about grid will get a notification every time a row is removed or added, Can we use _grd.BeginUpdate() to avoid this?
btw, Is there any reason that ultradDataSource doesn't support sort? It will be great that it supports sort as other data source.
No, there's no support in UltraDataSource for sorting rows.
You could try sorting the rows by removing and then re-inserting the row in the correct place, but I would not recommend this approach, since the grid will get a notification every time a row is removed or added.
What you will probably need to do is change the DataSource of your grid to a data source that has built-in sorting support like a DataTable.