When a user changes the layout of the grid (e.g., by column resize or reorder), I set value that's read on page_load. If the value is 1, I save the grid settings. This works fine for column resize, but not for column reorder, the value doesn't get updated (it remains 0). I have the column order client events pointing to the same event as column resize (as you can see below), but the method is never called. (I put a breakpoint on the client function and it's only called on column resize, not reorder).
Here's the grid definition:
And the method definition:
Why isn't the SaveSettingsOnClose method being called when I reorder or sort the columns on the grid?
The second issue has to do with Column sort. When I sort a column, the server OnSortCommand is called, but when I step through the code and check the grid sort expression count, it's always 0 (even though the visual state of the grid shows the proper sort method). Here's the OnSortCommand and followon StoreSettings methods:
Why is the .SortExpressions.Count set to 0 even though the grid appears to be sorted properly when looking at it?
Here's the grid definition:
<telerik:RadGrid ID="grdHistory" runat="server" OnItemCreated="grdHistory_ItemCreated" OnItemDataBound="grdHistory_ItemDataBound" OnNeedDataSource="grdHistory_NeedDataSource" OnPreRender="grdHistory_PreRender" OnSortCommand="grdHistory_SortCommand" OnPageSizeChanged="grdHistory_SaveSettingsOnClose" AutoGenerateColumns="true" SkinID="worklist" AllowCustomPaging="true" AllowPaging="true" AllowFilteringByColumn="false" Width="99%" > <HeaderContextMenu OnClientItemClicking="GridHeaderContextMenuOnClientItemClicking"> </HeaderContextMenu> <ClientSettings ColumnsReorderMethod="Reorder" EnablePostBackOnRowClick="false" ReorderColumnsOnClient="False" AllowColumnsReorder="True" AllowKeyboardNavigation="True"> <Scrolling AllowScroll="true" SaveScrollPosition="true" UseStaticHeaders="true" /> <Resizing ResizeGridOnColumnResize="false" AllowColumnResize="true" EnableRealTimeResize="false" AllowResizeToFit="true" /> <ClientEvents OnColumnShown="SaveSettingsOnClose" OnColumnHidden="SaveSettingsOnClose" OnColumnResized="SaveSettingsOnClose" OnColumnClick="SaveSettingsOnClose" OnColumnSwapped="SaveSettingsOnClose" OnColumnMovingToLeft="SaveSettingsOnClose" OnColumnMovingToRight="SaveSettingsOnClose" OnColumnMovedToLeft="SaveSettingsOnClose" OnColumnMovedToRight="SaveSettingsOnClose" OnMasterTableViewCreated="MasterTableViewCreated" OnKeyPress="preventInlineEditing" /> </ClientSettings> <MasterTableView commanditemdisplay="None" enablecolumnsviewstate="false" AllowPaging="True" AllowSorting="True" Width="100%"> <HeaderStyle Width="200px" /> <RowIndicatorColumn Visible="False"> </RowIndicatorColumn> </MasterTableView></telerik:RadGrid>And the method definition:
function SaveSettingsOnClose(sender, eventArgs) { triggerIsPostBack = true; document.getElementById('<%=hSaveSettingsOnClose.ClientID %>').value = "1";}Why isn't the SaveSettingsOnClose method being called when I reorder or sort the columns on the grid?
The second issue has to do with Column sort. When I sort a column, the server OnSortCommand is called, but when I step through the code and check the grid sort expression count, it's always 0 (even though the visual state of the grid shows the proper sort method). Here's the OnSortCommand and followon StoreSettings methods:
protected void grdHistory_SortCommand(object sender, GridSortCommandEventArgs e){ StoreLastSort();}private void StoreLastSort(){ if (grdHistory.MasterTableView.SortExpressions.Count > 0) { //Store the column sorted on for when we reload foreach (GridSortExpression gse in grdHistory.MasterTableView.SortExpressions) { string direction = (gse.SortOrder == GridSortOrder.Ascending) ? "ASC" : "DESC"; UserSettingHelper.SetUserSetting(SortSettingKey, gse.FieldName + "," + direction); } } else { UserSettingHelper.DeleteUserSetting(SortSettingKey); }}Why is the .SortExpressions.Count set to 0 even though the grid appears to be sorted properly when looking at it?
