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

refresh page on paging

8 Answers 473 Views
Grid
This is a migrated thread and some comments may be shown as answers.
L
Top achievements
Rank 1
L asked on 31 Aug 2011, 04:25 AM
hi

I have a radgrid that is ajaxified. All works fine except that i want a refresh of page when i do a paging on the grid. How should i go about it. Thanks

Sorry for any inconvenience caused.

8 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 31 Aug 2011, 06:41 AM
Hello,

I suppose you are using Simple databinding. In order to achieve this, use advanced databinding techniques using NeedDataSource event. This event fires whenever a paging operation occurs. Check the following help documentation which explains more about this.
Advanced Data-binding (using NeedDataSource event).

Thanks,
Princy.
0
L
Top achievements
Rank 1
answered on 31 Aug 2011, 08:05 AM
hi

This is my code and the page did not get refresh when i did a page navigation. thanks

   Protected Sub RadGrid1_NeedDataSource(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource
        RadGrid1.DataSource = Session("sessiondataset")

    End Sub

0
L
Top achievements
Rank 1
answered on 31 Aug 2011, 08:41 AM
hi

Sorry, i need to rephase my intention.

I have got it wrong when i used the word refresh a page, instead it should be forcing a postback of a radgrid when paging.

Thanks
0
Tsvetina
Telerik team
answered on 03 Sep 2011, 12:45 PM
Hello,

Do you mean that you want to make a postback instead of AJAX request when paging? If so, you could wire the client OnRequestStart event of the RadAjaxManager/Panel and cancel the request on certain condition. You could recognize the Page command in the client OnCommand event of RadGrid and raise a flag to use for checking in the OnRequestStart event handler.

Greetings,
Tsvetina
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
L
Top achievements
Rank 1
answered on 04 Sep 2011, 04:58 AM
hi

Yes i want the a postback when users do page navigation

I have gone through some of the forums and have taken this code and i am still wonder how should i go about it.

<script type="text/javascript">
    function RequestStart(sender, eventArgs)
    {
      var eventTarget = eventArgs.get_eventTarget();
      if (eventTarget.indexOf("Button1") != -1)
      {
        eventArgs.set_enableAjax(false);
      }

  function RaiseCommand(sender, args)
    {
        if (args.get_commandName() == 'Page')
        {
            args.set_cancel(false);
 
        }
    }

    }
  </script>

What should i replace with on the eventTarget.indexOf("Button1") != -1 since i am not using a button and how do i go about "You could recognize the Page command in the client OnCommand event of RadGrid and raise a flag to use for checking in the OnRequestStart event handler" Thanks and sorry for any inconvenience cause.
0
Tsvetina
Telerik team
answered on 06 Sep 2011, 02:26 PM
Hi,

Here is sample code that you could try. The OnCommand event checks whether the command is Page and raises a flag indicating to turn off AJAX for the current request which is done in OnRequestStart handler:
<%@ Page Language="C#" AutoEventWireup="true"  %>
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
    <style type="text/css">
         
    </style>
    <script type="text/C#" runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
 
            RadGrid1.DataSource = new object[]
  
        {
  
            new { Text = "1", MoreText = "More text than the previous field." },
  
            new { Text = "2", MoreText = "More text than the previous field." },
  
            new { Text = "3", MoreText = "More text than the previous field." },
  
            new { Text = "4", MoreText = "More text than the previous field." },
  
            new { Text = "5", MoreText = "More text than the previous field." },
  
            new { Text = "6", MoreText = "More text than the previous field." },
  
            new { Text = "7", MoreText = "More text than the previous field." },
  
            new { Text = "8", MoreText = "More text than the previous field." },
  
            new { Text = "9", MoreText = "More text than the previous field." },
  
            new { Text = "10", MoreText = "More text than the previous field." },
  
            new { Text = "11", MoreText = "More text than the previous field." },
  
            new { Text = "12", MoreText = "More text than the previous field." }
  
        };
 
            RadGrid1.DataBind();
 
        }
  
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        <Scripts>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
        </Scripts>
    </telerik:RadScriptManager>
    <div>
        <telerik:RadCodeBlock runat="server">
            <script type="text/javascript">
                var isPaging;
                function command(sender, eventArgs) {
                    if (eventArgs.get_commandName() == 'Page') {
 
                        isPaging = true;
                    }
                }
                function requestStart(sender, eventArgs) {
                    if (isPaging) {
                        eventArgs.set_enableAjax(false);
                    }
                }
            </script>
        </telerik:RadCodeBlock>
        <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" ClientEvents-OnRequestStart="requestStart">
            <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" AllowSorting="true"
                AllowPaging="true">
                <ClientSettings ClientEvents-OnCommand="command" />
                <MasterTableView>
                    <Columns>
                        <telerik:GridBoundColumn DataField="Text" ItemStyle-Width="200px" HeaderStyle-Width="200px"
                            HeaderText="Text">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="MoreText" ItemStyle-Width="200px" HeaderStyle-Width="200px"
                            HeaderText="More Text">
                        </telerik:GridBoundColumn>
                    </Columns>
                </MasterTableView>
            </telerik:RadGrid>
        </telerik:RadAjaxPanel>
    </div>
    </form>
</body>
</html>


Regards,
Tsvetina
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Krupa
Top achievements
Rank 1
answered on 22 Feb 2021, 05:28 PM
I am using Teleric grid 2013.2.611.340 with mvc project.  I am facing an issue where when I change paging and click on edit button of a particular record, it opens into a pop-up window. After updating the data and closing the window, it refreshes to the first page instead of the page opened. How can solve this issue?
0
Rumen
Telerik team
answered on 25 Feb 2021, 08:07 AM

Hi Krupa,

The Telerik ASP.NET AJAX controls are not designed and intended for use in MVC environment. Please check the following article on the matter: 

https://docs.telerik.com/devtools/aspnet-ajax/mvc/overview.

We recommend using the UI for ASP.NET MVC, the Telerik product built from the ground up to support the principles of MVC development in your MVC projects. The MVC suite is pretty mature and offers a similar amount of ASP.NET MVC components (100+).

You can play with the MVC Grid demos at https://demos.telerik.com/aspnet-mvc/grid.

On a side note, version 2013.2.611 of Telerik.Web.UI.dll is pretty old and does not support the latest browsers. 

Regards,
Rumen
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
L
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
L
Top achievements
Rank 1
Tsvetina
Telerik team
Krupa
Top achievements
Rank 1
Rumen
Telerik team
Share this question
or