Hi all,
I have a problem about create a custom sorting of WinGrid.
For example: When user click on header column to sorting, I want the grid still have indicator (and everything like default it be) but don't implement the default sorting because I will use my sorting for it.
How I do that?
Thanks a lot
Dan
Hi Alex,
I understood your suggestion and I knew that way.
Regarding to why I need to use SQL query instead of use default grouping, because in case we work with huge data, I think the grid will slow.
I want a solution similar with the way I already implemented for filtering (as I said above) but I don't know the properties will be use for it :( and do they exist? (just use a appearance and the grid will not do grouping)
So I think that's enough for me and I will try another way for this issue.
Thanks so much for your nice helping, Alex
Best regards,
I could not completely understand what do you mean by
"it mean our grid already have a datasource. But in my case, I want to bind another data source for the Grid"
Ultra Grid must have underlying data source in any case. You can bind a grid to a List of custom data objects for example, it does not necessarily to use Ultra Data Source only.
Regarding grouping of records... You should set ViewStyleBand to OutlookGroupBy:
grid.DisplayLayout.ViewStyleBand = Infragistics.Win.UltraWinGrid.ViewStyleBand.OutlookGroupBy;
to have default grouping appearance. But in this case you will get the fully functionality of a default grouping with ability to set your own logic for grouping columns via setting GroupByEvaluator to the corresponding columns like this:
GroupEvaluator eval = new GroupEvaluator();grid.DisplayLayout.Bands[0].Columns["MyColumn"].GroupByEvaluator = eval;
and in the next methods of GroupByEvaluator you can define your custom logic("Because I want to use my SQL query to group").
public object GetGroupByValue(UltraGridGroupByRow groupByRow, UltraGridRow row) { return null; // place your own logic } public bool DoesGroupContainRow(UltraGridGroupByRow groupByRow, UltraGridRow row) { return false; //place your own logic }
But what confuses me, however, is why you need to use SQL queries for grouping.
Is that not enough for you to achieve the custom grouping?
Alex.
But when we use GroupByEvaluator, it mean our grid already have a datasource. But in my case, I want to bind another data source for the Grid and just using the appearance of group event, nothing more.
Do the grid have a group's property to setting like RowFilterAction.AppearancesOnly?
Sorry to you because my bad english.
Thank you so much Alex
Dan,
If you want to use the custom logic for grouping records what you can do is create a custom GroupByEvaluator and assign it to the column.
You will have to create a class and implement IGroupByEvaluator interface. This interface allows you to determine which rows belong in the same group and which don't.
Note that the ICustomGroupByEvaluator will only get called to evaluate rows that are adjacent. So you may also need to implement a SortComparer on the column to make sure the column is sorted in the correct order before it is grouped.
Hope this helps.