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

GDBG. Nested tables and sorting

Thread ID:





15603 Jun 23,2004 11:39 AM UTC Jun 23,2004 12:36 PM UTC WinForms 1
Tags: GridControl
Asked On June 23, 2004 11:39 AM UTC

Hi all. I have two related tables in my dataset. How can I sort second table when user clicks on the columns headers?

Administrator [Syncfusion]
Replied On June 23, 2004 12:36 PM UTC

The child lists are only know while the parent node is expanded. So, you would have to dynamically sort the ChildList as the node is expanded. And when your user clicks on a child column header, you would have to go through all grid rows, sorting any childtable that is visible. Here is code that sorts a column named "Name" when a row is expanded.
private void gridDataBoundGrid1_RowExpanded(object sender, GridRowEventArgs e)
	GridBoundRecordState rs = this.gridDataBoundGrid1.Binder.GetRecordStateAtRowIndex(e.RowIndex);
	DataView dv = rs.ChildList as DataView;
	if(dv != null)
		dv.Sort = "Name";
		this.gridDataBoundGrid1.RefreshRange(GridRangeInfo.Rows(e.RowIndex + 1, e.RowIndex + rs.ChildCount));
So, on a cellclick, you would have to check to see if it was on one of your child headers, and if so, set a paramater (to play the role of "Name") in the above code so that when nodes are opened in the future, you would sort that column. You would also want to loop through all the rows in your grid, getting each GridBoundRecodState for each row, and use the same code as above to sort any child tables already opened.


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon

Live Chat Icon For mobile
Live Chat Icon