We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Sorting Problem in Grid

Hi, I have problem related Grouping in grid control while sorting. for example :- I have implemented Syncfusion Grid control, and now I am implementing sorting feature of grid control. In this grid control data is been groupd in logical way. So what I want is when I sort my grid control, it should short between those logical groups. So is this possible using Syncfusion''s grid control??? Thanks & Regards, Manoj Singh.

3 Replies

AD Administrator Syncfusion Team June 21, 2006 07:07 PM UTC

Hi Manoj, By clicking on the column header in the table you can sort the records WITHIN A GROUP. and clicking on the col header in the group drop area will sort the order of the GROUPS themselves. Are you looking for something to do like this in coding? (or) you want the user to be able to click on a column header in the table and that should result in forcing the Group order to be sorted. Could you please confirm what you are looking for. so that we will start creating a sample accordingly. Regards, A.Sivakumar


MS manoj singh June 22, 2006 04:20 AM UTC

Hi Siva, I am looking for second option, user should click on column header and that click should sort data within the logical groups. Regards, Manoj Singh. >Hi Manoj, > >By clicking on the column header in the table you can sort the records WITHIN A GROUP. and clicking on the col header in the group drop area will sort the order of the GROUPS themselves. Are you looking for something to do like this in coding? > >(or) > >you want the user to be able to click on a column header in the table and that should result in forcing the Group order to be sorted. > >Could you please confirm what you are looking for. so that we will start creating a sample accordingly. > >Regards, >A.Sivakumar


AD Administrator Syncfusion Team June 23, 2006 04:01 PM UTC

Hi Manoj, For the user to be able to click on a column header in the table and that result in forcing the order of the GROUPS could be done by listening to the ''SortedColumns changed'' event of the ''TableDescriptor of GridGroupingControl. Here is the steps and code snippet to acheive this behavior: step 1) Define handlers for the SortedColumns.Changed event in the Page_Init this.GridGroupingControl1.TableDescriptor.SortedColumns.Changed += new Syncfusion.Collections.ListPropertyChangedEventHandler(this.GridGroupingControl1_SortedColumnsChanged); step 2) Inside the GridGroupingControl1_SortedColumnsChanged Event check for the name of the sorted column //Retreive the name of the sorted column SortColumnDescriptor scd = (SortColumnDescriptor)e.Item; sortedcolumns = scd.Name; step 3) Check for the Action performed inside this event, here check for these 2 cases "Add" and "ItemPropertyChanged", Where the case "Add" gets called only for the first time and ''ItemPropertChanged'' there after a columns sorted direction is changed. step 4)Based on the sorted columns direction you can change the sorting order of the group as follows //forcing the first gridgroupedColumn''s sort direction to ascending. this.GridGroupingControl1.TableDescriptor.GridGroupedColumns[0].SortDirection = ListSortDirection.Ascending; [Sample code in c#] private void GridGroupingControl1_SortedColumnsChanged(object sender, Syncfusion.Collections.ListPropertyChangedEventArgs e) { string sortedcolumns; SortColumnDescriptor scd = (SortColumnDescriptor)e.Item; sortedcolumns = scd.Name; if (scd.Name == "sortedcolumn") // consider the sorted columns name is ''sortedcolumn'' { switch (e.Action) { case ListPropertyChangedType.Add: case ListPropertyChangedType.ItemPropertyChanged: { //Check for the ''sortedcolumns'' direction and force the groups to be sorted based on this. if (scd.SortDirection == ListSortDirection.Ascending) { this.GridGroupingControl1.TableDescriptor.GridGroupedColumns[0].SortDirection = ListSortDirection.Ascending; //You can also do by checking the name of the group to get the name of the group the code is as follows //this.GridGroupingControl1.TableDescriptor.GridGroupedColumns[0].Name retreives the name of the group } else if (scd.SortDirection == ListSortDirection.Descending) { this.GridGroupingControl1.TableDescriptor.GridGroupedColumns[0].SortDirection = ListSortDirection.Descending; } break; } } } } Also attached the sample illustrating this Click here to download the Sample Best Regards, A.Sivakumar.

Loader.
Live Chat Icon For mobile
Up arrow icon