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

Client side OnCommand page number issue

1 Answer 48 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Joe
Top achievements
Rank 2
Joe asked on 31 Mar 2011, 11:03 PM
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

1 Answer, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 04 Apr 2011, 07:57 AM
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
Tags
Grid
Asked by
Joe
Top achievements
Rank 2
Answers by
Vasil
Telerik team
Share this question
or