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.
Unfortunately, activation email could not send to your email. Please try again.

Sorting - Multicolumns with different setting for each column

Thread ID:

Created:

Updated:

Platform:

Replies:

78476 Dec 15,2008 11:04 AM Jan 8,2009 10:31 AM Windows Forms 5
loading
Tags: Grouping
Amit Chauhan
Asked On December 15, 2008 11:04 AM

Hi,

I have two non-standard feature requirement with Syncfusion Grouping Grid.

1. We would like to sort data (whereever numeric) by absolute and non-absolute values. 2. We would like some columns to have permament sorting (i.e change in sorted rows when new rows are added or data is updated) and temporary sorting (i.e dont change the sorted rows based on data update or new rows) in the same grouping grid.

Are above two features possible to implement. We use syncfusion 5.2. If yes, it would be of great help if someone can highlight how to go abt doing it.

As a general info, we bind the grouping grid to a DataTable, which is continuosly updated (both existing rows and with new rows).

Many thanks for response.

Amit


Rajadurai C [Syncfusion]
Replied On December 16, 2008 09:18 AM

Hi Amit,

Thanks for your interest in Syncfusion products.

1) To sort data by absolute and non absolute values, you can make use of class implementing IComparer interface that compares two objects for sorting.
Please refer the following sample that shows ggc using custom comparer for sorting
http://www.syncfusion.com/Support/user/uploads/GGC_SortGroup_d3632c3f.zip

2) If you want to disable sorting on changing values of the grid, then you need to use CustomSorting.
****************************************************************************************************************

The grid structures require to have the records always be sorted according to the sort order.

The only way you can get this working is if you do not let the grid engine do the sorting.

What you could do is have your own implementation of an IBindingList. This IBindingList should be filled with the data that you want to display in the grid.

You could then listen to the click event on the column header and then do a custom sorting yourself.

When you handle the sort you could then manually sort your list and after that raise a ListChangedType.Reset event so that the grid knows the records were changed.

You should not modify the grid SortColumns collection.

If you do it this way the grid will simply display the records in the order as they are in your custom list and when you change contents of a record or add a record it will not need to sorted.

It will however not work if you also require grouping columns...

Regards,
Rajadurai


Amit Chauhan
Replied On December 17, 2008 10:01 AM

Thanks Rajadurai.

I will try the first option for absolute and non-abs sorting.

For second option, unfortunately we have a huge datatable to which we bind the grid. So implementing a new data structure with IBindingList would not be feasible. I may try with DataView instead. i.e sorting on the dataview. If it works, I will post the way to achieve permanent sorting and temporary sorting together.

Thanks
Amit

>Hi Amit,

Thanks for your interest in Syncfusion products.

1) To sort data by absolute and non absolute values, you can make use of class implementing IComparer interface that compares two objects for sorting.
Please refer the following sample that shows ggc using custom comparer for sorting
http://www.syncfusion.com/Support/user/uploads/GGC_SortGroup_d3632c3f.zip

2) If you want to disable sorting on changing values of the grid, then you need to use CustomSorting.
****************************************************************************************************************

The grid structures require to have the records always be sorted according to the sort order.

The only way you can get this working is if you do not let the grid engine do the sorting.

What you could do is have your own implementation of an IBindingList. This IBindingList should be filled with the data that you want to display in the grid.

You could then listen to the click event on the column header and then do a custom sorting yourself.

When you handle the sort you could then manually sort your list and after that raise a ListChangedType.Reset event so that the grid knows the records were changed.

You should not modify the grid SortColumns collection.

If you do it this way the grid will simply display the records in the order as they are in your custom list and when you change contents of a record or add a record it will not need to sorted.

It will however not work if you also require grouping columns...

Regards,
Rajadurai




Rajadurai C [Syncfusion]
Replied On December 19, 2008 01:29 AM

Hi Amit,

Thanks for your update.

Please let me know once you achieved this with provided suggestions.

Regards,
Rajadurai


Amit Chauhan
Replied On January 6, 2009 01:42 PM

Hi Rajadurai,

I have another interesting issue. This time with editable column we have on grid. Once I sort the column, the rows are sorted nicely as one would expect. However I now go and edit the a value in one of the rows, the row jumps to a different location (i.e the rows are sorted). However, I do not want the row to jump, especially when user is editing the data. Is there a way to suppress the Sorting event on lets say RecordValueChanging, if the column which is being edited is also available in the list of sorted columns.

Thanks for help.

Regards
Amit


Rajadurai C [Syncfusion]
Replied On January 8, 2009 10:31 AM

Hi Amit,

Apologies for the delay caused.

It is the general behavior for SortedColumns property in gridgroupingcontrol to sort on leaving a record after editing.

I don't find a way to cancel the sorting provided the column is in the sorting list. If you don't want to sort after editing, then you can handle this adding and removing of sorted column through button click event. Please refer to the following steps:

1. Place a button in form near the gridgroupingcontrol.

2. Don't add the column in the sorted column list in the beginning.

3. In the button_Click event handler, add the column by which the group has to be sorted. Here is the code snippet:


private void button1_Click(object sender, EventArgs e)
{
if (!this.gridGroupingControl1.TableDescriptor.SortedColumns.Contains("Country"))
{
this.gridGroupingControl1.TableDescriptor.SortedColumns.AddRange(new Syncfusion.Grouping.SortColumnDescriptor[] {
new Syncfusion.Grouping.SortColumnDescriptor("Country", System.ComponentModel.ListSortDirection.Ascending)});
}
}


By doing this, the table initially appears in the unsorted manner. After making changes in the records, on clicking the button, the column by which sort take place is added and sorted along with the changes made.

Please let me know if you have any futher concerns.

Regards,
Rajadurai


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;