I have a grid that's using the following settings:
When sorting using the header context menu, unlike just clicking on the header, no SortCommand event is fired. I found a thread where you recommended using the ItemClick event on the header.
The problem is that this event is called after the grid rebinds once you click it, and even if you explicitely call RadGridTest.Rebind() in the event it doesn't take it. The only solution I've found so far is to set the datasource to null and then call rebind.
Is setting the datasource to null the correct approach, or is there something I am missing.
<telerik:RadGrid ID="RadGridTest" runat="server" AllowPaging="True" AllowCustomPaging="True" GridLines="None" OnNeedDataSource="RadGridTest_NeedDataSource" PageSize="25" OnItemDataBound="RadGridTest_ItemDataBound" AutoGenerateColumns="false" EnableHeaderContextMenu="true" EnableLinqExpressions="false" EnableHeaderContextFilterMenu="true" AllowSorting="True" MasterTableView-AllowCustomSorting="true" OnSortCommand="RadGridTest_SortCommand" MasterTableView-AllowMultiColumnSorting="true" AllowFilteringByColumn="true"> <PagerStyle Mode="NextPrevAndNumeric/> <HeaderContextMenu OnItemClick="HeaderContextMenu_ItemClick"> </HeaderContextMenu> <ClientSettings AllowColumnHide="True"> <ClientEvents OnGridCreated="GetGridObject"></ClientEvents> </ClientSettings></telerik:RadGrid>When sorting using the header context menu, unlike just clicking on the header, no SortCommand event is fired. I found a thread where you recommended using the ItemClick event on the header.
The problem is that this event is called after the grid rebinds once you click it, and even if you explicitely call RadGridTest.Rebind() in the event it doesn't take it. The only solution I've found so far is to set the datasource to null and then call rebind.
// Doesn't change the grid at allprotected void HeaderContextMenu_ItemClick(object sender, RadMenuEventArgs e){ if (e.Item.Text == "Clear Sorting") { string columnName = e.Item.Attributes["ColumnName"]; // ["columnUniqueName"] Returns Null!? // Prepare conditions for sorted data RadGridTest.Rebind(); // Never actually raises NeedDataSource }}// Updates the grid with the correct changes.protected void HeaderContextMenu_ItemClick(object sender, RadMenuEventArgs e){ if (e.Item.Text == "Clear Sorting") { string columnName = e.Item.Attributes["ColumnName"]; // ["columnUniqueName"] Returns Null!? // Prepare conditions for sorted data RadGridTest.DataSource = null; RadGridTest.Rebind(); }}Is setting the datasource to null the correct approach, or is there something I am missing.