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

RadDataPagerNumericPageSizeField with Enter Key using default button

5 Answers 62 Views
DataPager
This is a migrated thread and some comments may be shown as answers.
Cradz
Top achievements
Rank 1
Cradz asked on 03 Mar 2014, 06:33 PM
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).





5 Answers, 1 is accepted

Sort by
0
Cradz
Top achievements
Rank 1
answered on 03 Mar 2014, 06:45 PM
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.
0
Viktor Tachev
Telerik team
answered on 06 Mar 2014, 02:43 PM
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!

0
Cradz
Top achievements
Rank 1
answered on 06 Mar 2014, 04:38 PM
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.
0
Viktor Tachev
Telerik team
answered on 11 Mar 2014, 11:51 AM
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.

0
Kalpesh
Top achievements
Rank 1
answered on 09 Apr 2014, 11:59 AM
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;
  });
}


Tags
DataPager
Asked by
Cradz
Top achievements
Rank 1
Answers by
Cradz
Top achievements
Rank 1
Viktor Tachev
Telerik team
Kalpesh
Top achievements
Rank 1
Share this question
or