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

griddataboundgrid sort

When i click on a column the griddataboundgrid should sort by that particular column.

2 Replies

SK Santosh Kandhukuri April 29, 2010 09:57 PM UTC

I tried this example
http://www.syncfusion.com/support/kb/784/How-can-I-restrict-the-sorting-of-the-particular-column-on-Header-click-

This example didnt work for me. I am unable to double click the header at all.




CI Christopher Issac Sunder K Syncfusion Team May 15, 2010 10:38 AM UTC

Hi Santosh,

We appreciate your interest in Syncfusion products.

You can try the given sample which illustrates the CellClick event as well as CellDoubleClick event in GridDataBoundGrid Sorting. You can also make use of manual sorting instead of setting the gridDataBoundGrid1.SortBehavior by handling the DataTable directly through DataView with the following code.

void gridDataBoundGrid1_CellClick(object sender, GridCellClickEventArgs e)
{
if ((e.ColIndex == 1 || e.ColIndex == 3)
&& e.RowIndex == 0)
{
int filed = this.gridDataBoundGrid1.Binder.ColIndexToField(e.ColIndex);
string name = this.gridDataBoundGrid1.Binder.InternalColumns[filed].MappingName;
string sort = myDataTable.DefaultView.Sort.Contains(name) ? (myDataTable.DefaultView.Sort.Contains("ASC") ? "DESC" : "") : "ASC";
if (sort.Length > 0)
myDataTable.DefaultView.Sort = "[" + name + "] " + sort;
else
myDataTable.DefaultView.Sort = String.Empty;
e.Cancel = true;
this.gridDataBoundGrid1.Refresh();
}
}


Suppose, If you need to sort the Column with double click, you can make a try with the following code snippet.

this.gridDataBoundGrid1.SortBehavior = GridSortBehavior.DoubleClick;

And to capture the double click on the cell, you can use the CurrentCellControlDoubleClick event instead of CellDoubleClick event.

Please refer the following sample link which illustrates the behavior of CellClick, CellDoubleClick and CurrentCellControlDoubleClick in GridDataBoundGrid.

http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=GDBG-662623379.zip

Let me know if you have any further concerns.

Regards,
Christopher K.

Loader.
Live Chat Icon For mobile
Up arrow icon