History Points and RadGrid

2 posts, 0 answers
  1. Justin
    Justin avatar
    13 posts
    Member since:
    Feb 2011

    Posted 22 Feb 2012 Link to this post

    I'm hoping someone can help me by either pointing me to a straight forward example or pointing out the error(s) in my code.  I'm attempting to provide history points when a user is interacting with an ajax grid.  I've started just with paging but eventually want to get this working with sorting as well.  

    I have a master page which defines a RadScriptManager:

    <telerik:RadScriptManager ID="RadScriptManager1" runat="server" EnablePartialRendering="true" EnableHistory="true" EnableSecureHistoryState="false"></telerik:RadScriptManager>

    On a content page I have a ScriptManagerProxy to invoke the OnNavigate event (when a browser back/forward button is clicked):

    <asp:ScriptManagerProxy ID="ProxyScriptManager" runat="server" OnNavigate="ScriptManager_OnNavigate" />

    The ScriptManager_OnNavigate handler is defined as such:

    protected void ScriptManager_OnNavigate(object sender, HistoryEventArgs e)
                if (e.State.Count <= 0)
                    // setup default state
                    RadGrid1.MasterTableView.CurrentPageIndex = 0;
                string key = e.State.AllKeys[0];
                string state = string.Empty;
                if (string.Equals(key, GridPageHistoryKey))
                    state = e.State[key];
                    int pageIndex;
                    if (int.TryParse(state, out pageIndex))
                        RadGrid1.MasterTableView.CurrentPageIndex = pageIndex;

    On the grid's OnPageIndexChanged event handler, I set a private variable to true which is then checked in the grids OnPrerender event:

    protected void RadGrid1_PageIndexChanged(object sender, GridPageChangedEventArgs e)
                _saveState = true;

    protected void RadGrid1_PreRender(object sender, EventArgs e) {
    if (_saveState)
                    if (RadScriptManager.GetCurrent(this.Page).IsInAsyncPostBack && !RadScriptManager.GetCurrent(this.Page).IsNavigating)
                        var state = RadGrid1.MasterTableView.CurrentPageIndex.ToString();
                        RadScriptManager.GetCurrent(this.Page).AddHistoryPoint(GridPageHistoryKey, state);

    It appears that the add history point is getting created and the OnNavigate code is executing but the grid doesn't update when clicking the back button.  Am I missing a crucial step?  Is there an example that doesn't just point me to:  http://www.telerik.com/help/aspnet-ajax/ajax-back-forward-btns.html 

    Thanks for any help!

  2. Walter
    Walter avatar
    11 posts
    Member since:
    Apr 2009

    Posted 20 Mar 2012 Link to this post

    Have you put your radgrid in the RadAjaxManager so it will be updated if the RadScriptManager triggers it ?

    <telerik:RadAjaxManagerProxy ID="ramProxy" runat="server">
                <telerik:AjaxSetting AjaxControlID="RadScriptManager1">
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1"  />

  3. DevCraft R3 2016 release webinar banner
Back to Top