RadDataPagerNumericPageSizeField with Enter Key using default button

6 posts, 0 answers
  1. Cradz
    Cradz avatar
    65 posts
    Member since:
    Nov 2005

    Posted 03 Mar 2014 Link to this post

    I have two data controls that users can switch between, one a datagrid and one a RadListView that is tied to the datapager below:

       <telerik:RadDataPager ID="RadDataPager1" runat="server" PagedControlID="listResults" PageSize="20">
                                          <Fields>
                                    <telerik:RadDataPagerButtonField FieldType="FirstPrev" />
                                    <telerik:RadDataPagerButtonField FieldType="Numeric"  />
                                    <telerik:RadDataPagerButtonField FieldType="NextLast" />
                                   <telerik:RadDataPagerNumericPageSizeField LabelText="Page Size:" SubmitButtonText="Change"  TextBoxWidth="25" Visible="true" />
                                    <telerik:RadDataPagerGoToPageField CurrentPageText="Page: " TotalPageText="of" SubmitButtonText="Go" TextBoxWidth="30" />
                                    
                                </Fields>
                                         </telerik:RadDataPager>

    The datagrid works just fine when changing the page size and hitting the enter key. The RadListView version I have with datapager does not.

    I ended up just creating a hidden submit button and setting the default button for the whole page to that but really this is just a work around and to me the RadDataPagerNumericPageSizeField in RadDatapager should act just like the pager control built in to RadDatagrid.

    With the hidden submit button the Datagrid still acts normally when changing the page size and hitting enter (which is great and the way I want it to act).





  2. Cradz
    Cradz avatar
    65 posts
    Member since:
    Nov 2005

    Posted 03 Mar 2014 in reply to Cradz Link to this post

    For anybody wanting to use the fix I describe above to stop the enter key from submitting the page with the first button it comes across on the page here is the code:

    <form id="form1" runat="server" defaultbutton="MyDefaultButton">

    <asp:Button ID="MyDefaultButton" runat="server" Style="display: none;" OnClientClick="return false;" />

    I don't need a default button set so this works for me. Sucks if you need to use a default button but want the RadDataPager using RadDataPagerNumericPageSizeField to act correctly when somebody enters a value and hits the enter key.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 06 Mar 2014 Link to this post

    Hi,

    I am afraid that currently pressing enter when typing a page number in the RadDataPager's TextBox would not trigger page command automatically.

    In order to achieve such behavior you could use RadDataPagerTemplatePageField and use custom logic to trigger paging manually. The following markup illustrates how this could be implemented.

    <telerik:RadDataPagerTemplatePageField>
        <PagerTemplate>
            <telerik:RadNumericTextBox runat="server" ID="TextBox1" NumberFormat-DecimalDigits="0" ClientEvents-OnValueChanged="pagerTextBoxValueChanged" ></telerik:RadNumericTextBox>
        </PagerTemplate>
    </telerik:RadDataPagerTemplatePageField>

    The OnValueChanged handler would look similar to the one below.

    function pagerTextBoxValueChanged(sender, args) {
        var dataPager = $find("<%= RadDataPager1.ClientID %>");
        var targetPage = sender.get_value() - 1;
        dataPager.fireCommand("Page", targetPage);
    }


    Regards,
    Viktor Tachev
    Telerik

    DevCraft Q1'14 is here! Join the free online conference to see how this release solves your top-5 .NET challenges. Reserve your seat now!

  5. Cradz
    Cradz avatar
    65 posts
    Member since:
    Nov 2005

    Posted 06 Mar 2014 in reply to Viktor Tachev Link to this post

    Thanks Viktor,

    While I appreciate the reply this doesn't really resolve the issue. ClientEvents-OnValueChanged isn't available for the RadDataPagerNumericPageSizeField. The reason I use telerik is to make things as simple as possible so I can focus on other things. If I were to implement what you're talking about I'd have to start messing with custom code in the code behind to manage the value in "TextBox1" won't I?

    I'll just disable the ability to hit enter but to me this is a bug that needs to be fixed as the paging features of RadGrid work correctly.
  6. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 11 Mar 2014 Link to this post

    Hello,

    I am afraid that currently the functionality you describe could be achieved by using custom code and forcing the control to navigate to given page when pressing enter.

    I have logged this functionality in our system and you could view it in our feedback portal here. You could also vote for the item to increase its priority.

    Regards,
    Viktor Tachev
    Telerik

    DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

  7. Kalpesh
    Kalpesh avatar
    5 posts
    Member since:
    Dec 2013

    Posted 09 Apr 2014 Link to this post

    I have done similar for the textbox availble to enter the page number. Below is the code

    // Restrict hitting enter key on pager text box
    function DisablePagerTextboxEnterHit()
    {
      $(".riTextBox.riEnabled").keypress(function (event)
      {
        var code = navigator.appName == "Netscape" ? event.which : event.keyCode;
        if (code == 13)
          return false;
        else
          return true;
      });
    }


Back to Top
UI for ASP.NET Ajax is Ready for VS 2017