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.

GDBG. Nested tables and sorting

Thread ID:

Created:

Updated:

Platform:

Replies:

15603 Jun 23,2004 07:39 AM Jun 23,2004 08:36 AM Windows Forms 1
loading
Tags: GridControl
Silenter
Asked On June 23, 2004 07:39 AM

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 08:36 AM

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.

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.

;