Client side OnCommand page number issue

2 posts, 0 answers
  1. Joe
    Joe avatar
    48 posts
    Member since:
    Dec 2007

    Posted 31 Mar 2011 Link to this post

    Hi,

    I recently attached a javascript event handler the client event OnCommand. I noticed that when I select a page using the numeric pager, the command argument for the event is the page number. For instance, I select page 1, the command name is 'Page' and the command argument is 1. When I select page 1 using the master table view set_currentPageIndex, I get the command name 'Page', but the command argument is 0, the index value I passed to the function. This has caused me some difficulty as I don't necessarily have a way of determining how the event was originally triggered.

    Obviously it would be preferable if it used either the page number or the index, but not both.

    I am currently on 2010 Q2.

    Thanks,
    Joe

  2. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 04 Apr 2011 Link to this post

    Hello Joe,

    You should use the MasterTableView's page function instead of set_currentPageIndex property.
    For example, if you use the code bellow you will get the same alert when clicking on the second numeric pager button and the external one.
    <script type="text/javascript">
      function CommandHandler(sender, args) {
        alert("Argument: " + args.get_commandArgument());
      }
      function ChangePageIndex(pageIndex) {
        var grid = $find("<%=RadGrid1.ClientID %>");
        var mtv = grid.get_masterTableView();
        mtv.page(pageIndex);
      }
    </script>
    <div>
      <telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource"
        PageSize="3" AllowPaging="true">
        <ClientSettings>
          <ClientEvents OnCommand="CommandHandler" />
        </ClientSettings>
      </telerik:RadGrid>
      <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="ChangePageIndex(2); return 0;" />
    </div>

    Best wishes,
    Vasil
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top