This is a migrated thread and some comments may be shown as answers.

Browser Back button and reset PageIndex in Grid

6 Answers 124 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bryan
Top achievements
Rank 1
Bryan asked on 15 Nov 2012, 04:20 PM
Hello,
I know Telerik Grid does not go back to previous state in case of paging when ajaxfied but i found from telerik we can impement Scriptmanager Naviate method to reset Index but its not working it always go for first index on browser back button.
I have scriptmanager in MasterPage and in webpart i have added script manage Proxy control.

Please find code 
<asp:ScriptManager id="ScriptManager" runat="server"
                       EnableHistory="true"
                       EnablePageMethods="false"
                       EnablePartialRendering="true"
                       EnableScriptGlobalization="true"
                       EnableScriptLocalization="true" />

in Webpart .ascx File
<asp:ScriptManagerProxy ID="wsScriptManagerProxy" runat="server" OnNavigate="ScriptManager_Navigate" />

Code 

private static string pageKey = "p";
protected void ScriptManager_Navigate(object sender, HistoryEventArgs e)
        {
            if (e.State.Count <= 0)
            {
                // Setup default state
                workspaceGrid.MasterTableView.CurrentPageIndex = 0;
                return;
            }
 
            string key = e.State.AllKeys[0];
            string state = String.Empty;
 
            if (String.Equals(key, pageKey))
            {
                state = e.State[key];
                int pageIndex = int.Parse(state);
                workspaceGrid.MasterTableView.CurrentPageIndex = pageIndex;
                workspaceGrid.MasterTableView.Rebind();
            }
        }
protected void workspaceGrid_PageIndexChanged(object sender, GridPageChangedEventArgs e)
        {
            //string state = (sender as RadGrid).MasterTableView.CurrentPageIndex.ToString();
            string state = e.NewPageIndex.ToString();
            ScriptManager.GetCurrent(this.Page).AddHistoryPoint(pageKey, state);
        }

Thanks 
Ronak

6 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 20 Nov 2012, 12:48 PM
Hello Ronak,

Attached to this message is a sample runnable project which demonstrates how the desired functionality can be achieved. If this not works for you you can open a formal support ticket and send us a sample runnable project or modify the attached one in order to replicate the issue you a facing. Thus we will be able to review it locally and advice you further.

Kind regards,
Pavlina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Bryan
Top achievements
Rank 1
answered on 20 Nov 2012, 01:27 PM
Thanks Pavlina for your reply and code.I will give it try but it will be great if you provide code which best suit to my case like having scriptManager control in master page and SciptmanagerProxy control in content page.

Thanks 
Ronak
0
Bryan
Top achievements
Rank 1
answered on 20 Nov 2012, 03:25 PM
Thanks but its not working in my case.i am trying to achieve this in sharepoint webpart.

Thanks 
Ronak
0
Pavlina
Telerik team
answered on 23 Nov 2012, 05:04 PM
Hi,

Can you verify that the state of the grid pager is persisted in SharePoint when RadAjax is disabled(EnableAjax property is set to false) and you click browser back button? You can also check if the state of the other control features can be persisted from back button in SharePoint.

Kind regards,
Pavlina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Bryan
Top achievements
Rank 1
answered on 26 Nov 2012, 02:06 PM
Thanks Pavlina,yes it persist when i disable ajax 

Thanks 
Ronak
0
Tsvetoslav
Telerik team
answered on 28 Nov 2012, 01:52 PM
Hello Bryan,

Please, open up a formal support ticket and attache the implementation of the web part - it is difficult going by the code-snippets provided to say what exactly is going wrong with the code. Thanks for that.


Regards, Tsvetoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Bryan
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Bryan
Top achievements
Rank 1
Tsvetoslav
Telerik team
Share this question
or