Changing page size should reset page index

26 posts, 0 answers
  1. none123456
    none123456 avatar
    17 posts
    Member since:
    Aug 2007

    Posted 03 Jan 2008 Link to this post

    I'm using a RadGrid with a PagerStyle of NextPrevNumericAndAdvanced with VirtualItemCount. Suppose there are 100 rows in the data source, and the default page size is 50 rows. If the user changes to the second page, and then changes the page size to 100 rows. Even after changing the page size, the page index stays on the second page, and no rows are displayed (the NoRecordsTemplate displays).

    Can you change the grid to reset the page index to 0 any time the page size is changed?

    Thanks,

    David
  2. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 07 Jan 2008 Link to this post

    Hi dmatson,

    Indeed the page index is retained by default when you change the page size. This is because some of the users may want to be able to see additional number of records for the current page instead of navigating automatically back to the first page.

    For your situation you may consider subscribing to the PageSizeChanged (which is raised when you change the page size) and set the CurrentPageIndex to 0 inside the event handler. Thus the active page will be reset to the first.

    Best regards,
    Stephen
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Gregory Ott
    Gregory Ott avatar
    7 posts
    Member since:
    Aug 2007

    Posted 07 Jan 2008 Link to this post

    I understand that it is possible to code this functionality manually, so that is one possible solution. However, I was wondering if this functionality could be included by default in the control itself in the future.

    I tried thinking about it, and I can't think of a scenario where the user wouldn't want to go back to the first page when the page size changes. The only case I could think of is when the user is on the first page and changes the size, then it is fine to stay on the current page and see more or fewer records. However, that only makes sense with the first page, and resetting the page index here wouldn't affect this scenario.

    In all other cases, the user is likely to lose records currently displayed.
    For example, suppose the user is on page 2, displaying records 11-20 of 30. If the user changes the page size from 10 to 20, the user will now see records 21-30. All records previously displayed will no longer be visible.
    Similarly, if the user changes the page size from 10 to 5, records 6-10 will be displayed. Again, all records previously displayed will no longer be visible.

    It seems the most common (perhaps exclusive) usage would be to have the page index reset automatically when changing page size. If so, could that logic be included in the control automatically?

    Thanks for considering this suggestion.

    David
    (Sorry, I accidentially posted under the wrong account, so the name is wrong.)
  5. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 11 Jan 2008 Link to this post

    Hello David,

    This will be included in the upcoming service pack (next week).

    Kind regards,
    Vlad
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. ashish
    ashish avatar
    28 posts
    Member since:
    Jun 2012

    Posted 01 Jul 2008 Link to this post

    Did this ever happen?

    I am with David on this. Also, when a rebind occurs from an external source (When a new search is issued) also the page should reset to 0

    Pl advise when this will be available. if it is already please advise on how to get this service pack
  7. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 08 Jul 2008 Link to this post

    Hello ashish,

    I have verified this and it seems that this change was not included - we added this for our upcoming Q2 release.

    Greetings,
    Vlad
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  8. Alexey
    Alexey avatar
    8 posts
    Member since:
    Apr 2008

    Posted 31 Jul 2008 Link to this post

    Hello,

    I've found also that PageSizeChanged event fires EVERY TIME (on every postback), if PageSize is set using ASP.NET skin.

    I've created a skin, defined PageSize there, used that skin on my grid and now on every postback in the grid (for example, sorting or page change) I get that PageSizeChanged event.

    Another bug: setting PageSize by user and then hitting corresponding button DOES NOT change grid's PageSize property. Thats why we are using PageSize in a skin ;-) I've tested that behavior - in the Request.Form variables I can see CORRECT value - 20 (entered by user) BUT grid after postbacl will show again defaul 10 rows per page.

    I'm using Q1 Prometheus
  9. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 31 Jul 2008 Link to this post

    Hi Alexey,

    Can you please check whether the issues you encountered are address in the latest Q2 2008 version of RadControls for ASP.NET AJAX (2008.2.723)? It seems that you are using an outdated version of our components and the problems you encountered should be addressed.

    Best regards,
    Stephen
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  10. Alexey
    Alexey avatar
    8 posts
    Member since:
    Apr 2008

    Posted 31 Jul 2008 Link to this post

    Sure, I'll try latest release. I'm using this version:

    Telerik.Web.UI 2008.1.415.20 trial version.

    I've posted some other bugs for PageSizeChanged event - please let me know if they were addressed as well in the new version ;-) I'd be happy to get that things working now.
  11. Alexey
    Alexey avatar
    8 posts
    Member since:
    Apr 2008

    Posted 31 Jul 2008 Link to this post

    Hi,

    here is report on the latest available version: 2008.2.723.20

    Now PageSizeChanged event works correctly (almost): for some reason it fires TWICE but now it has correct value for NewPageSize ;-) Anyway, I can live with this.

    Now the issue is WHY do you reset the value of PageSize after ANY postback, like sorting & changing a page number ?

    User need to have page size the same - once he changed it. Sorting, navigating between pages should NOT affect page size.
  12. Vlad
    Vlad avatar
    115 posts
    Member since:
    Dec 2007

    Posted 31 Jul 2008 Link to this post

    Alexey,

    I suspect that ViewState is turned off in your case.

    Vlad
  13. Alexander
    Alexander avatar
    152 posts
    Member since:
    Jun 2012

    Posted 29 Aug 2008 Link to this post

    I have problem with pagesize, even if viewstate is turned on.

    So, i have a separate control that is a filter: set of textboxes that should filter out data in my telerik grid.

    When i apply filter - page size of the grid is reset :(

    I got the idea to find control named 'ChangePageSizeTextBox' in, let's say, page_load event and assign its value to the grid pagesize property. But I must find the control recursively, coz on some pages grid is placed inside formedit. So it's not very optimal.

    Do you have another suggestions how to make pagesize not be reset?
  14. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 29 Aug 2008 Link to this post

    Hello Alexander,

    I tested the grid from this online demo choosing advanced pager and enabling the filtering feature of the control. The new page size was retained as expected in my test - can you please test that on your end? Any further details regarding difference configuration settings you might have for your grid can help us track down the core of the problem to address it accurately.

    Best regards,
    Stephen
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  15. Alexander
    Alexander avatar
    152 posts
    Member since:
    Jun 2012

    Posted 29 Aug 2008 Link to this post

    Hi! INLINE filtering (in the headers) works ok, but I can't use them, i use 'hand-made' controls with set of asp:textbox, some of them are date range (that can't be reproduced with inline filter)

    So - could pagesize be retained when using postbacks NOT from telerik grid controls?

    p.s. I tried to find control recursively:

    ChangePageSizeTextBox 

    on the page to extract entered page size value. But strange - there are 2 such controls! And the first that i find is NOT the one i want, Request.Form[this_control.UniqueID] gives NULL! :(

  16. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 01 Sep 2008 Link to this post

    Hi Alexander,

    Thank you for the additional information.

    Basically, the page size should be retained when you commit a postback from another control on the page. Nevertheless, if you want to ensure that the page size is applied as expected after you perform custom filtering through your set of controls, merely set the PageSize property of the master table from your postback event handler and invoke the Rebind() method of the grid.

    Additionally, to set the PageSize in the relevant textbox from the pager, access the pager using the GetItems(itemType) method of the grid and locate the textbox by its id with the FindControl(id) method. Review the following article from the online help for more info.

    Best regards,
    Stephen
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  17. Alexander
    Alexander avatar
    152 posts
    Member since:
    Jun 2012

    Posted 01 Sep 2008 Link to this post

    Thank you for the answer.
    I've tried to use GetItems(GridItemType.Pager).First().FindControl("ChangePageSizeTextBox").Text to get entered page size value from _ItemCreated event, but keep getting 100, no matter what I've entered!! I tried to turn view state on and off, but it does not matter: entered value is somewhere in other place, because page size DOES get changed actually, however I cannot CATCH entered value.

    Please, help.
  18. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 01 Sep 2008 Link to this post

    Hi Alexander,

    How many items does the GetItems(itemType) method returns in your case? You may need to refer to the second item in the collection as you may have top and bottom pager rendered for the grid (the top pager is hidden by default).

    If this does not help, isolate a working subset of your project, exhibiting the abnormality, and send it enclosed to a formal support ticket. I will examine it in detail and will get back to you with more info on the subject.

    Best regards,
    Stephen
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  19. Alexander
    Alexander avatar
    152 posts
    Member since:
    Jun 2012

    Posted 01 Sep 2008 Link to this post

    Hi,

    i've succeeded in finding CORRECT page size value - it was really matter of bottom pager. And when I use submit controls from the grid - page size, page number - everything works nice!

    However, problem remained: when submit is NOT from within telerik grid control - assigning CORRECT page size value to grid property does not affect actual page size value, which remains:
    1) = 10, if there is no page size value indicated in grid skin file
    2) = value in grid skin file if it's indicated there

    I suspect for some reason it's being reset again to this WRONG - default value - somewhere later, not in MY code...

    Alas, I cannot send the ticket, because our client still have not bought trial version and trial support period is over (> 60 days)
  20. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 02 Sep 2008 Link to this post

    Hi Alexander,

    Do you explicitly call Rebind() after you assign the page size from the outer control postback handler? This should ensure that the page size value will be reflected accordingly.

    If you are unable to solve the issue yourself, paste the code snippets related to your grid instance (aspx and code-behind) in this forum post. I will review them and will advice you further.

    Best regards,
    Stephen
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  21. Alexander
    Alexander avatar
    152 posts
    Member since:
    Jun 2012

    Posted 02 Sep 2008 Link to this post

    Hi, rebind() does not help.

    Here is the relevant code:
    http://www.ciklum.net/B4R/PageSizeProblem.zip
  22. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 05 Sep 2008 Link to this post

    Hello Alexander,

    Unfortunately it seems that the zip attachment has been removed from the site administrator and I am not able to reach and download it (receiving 'Page can not be found' error). Can you please verify that the sample is accessible in order to be able to proceed with our investigation? Thanks.

    Best regards,
    Stephen
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  23. Alexander
    Alexander avatar
    152 posts
    Member since:
    Jun 2012

    Posted 05 Sep 2008 Link to this post

    Really, work of our administrators :)

    http://ftp.ciklum.net/B4R/PageSizeProblem.zip
    is new link

    Thanks.
  24. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 08 Sep 2008 Link to this post

    Hello Alexander,

    I reviewed your sample along with the custom classes in it and found the following method which performs a recursive loop through the page controls:

           public Control FindControlRecursive(Control root, string id) 
            { 
                Control result = null
     
                if (root.ID == id) 
                { 
                    result = root; 
                } 
                else 
                { 
                    foreach (Control ctl in root.Controls) 
                    { 
                        Control foundCtl = FindControlRecursive(ctl, id); 
                        if (foundCtl != null
                        { 
                            controlList.Add(foundCtl); 
                        } 
                    } 
                } 
     
                return result; 
            } 

    Note that this might cause some problems if the Controls collection of the grid is accessed early in the page lifecycle (this is discussed in the following KB article and is applicable for the ASP.NET AJAX version of the grid, too).

    Can this be the reason for the issue you experience? Does avoiding this iteration make a difference?

    On the other hand, what happens if the class from the code-behind of the page holding the grid extends directly the System.Web.UI.Page class instead of your custom class? Test that and if the problem remains please isolate a fully functional working subset of your project and send it attached to a support ticket.

    In order to be allowed to start support tickets, download another trial version of RadControls for ASP.NET AJXA from our site to receive additional 60 days support.



    Best regards,
    Stephen
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  25. nabil
    nabil avatar
    1 posts
    Member since:
    Mar 2009

    Posted 26 Mar 2009 Link to this post

    شكرا جزيلا على هذة الادوات الجميلة
    nabil

    [edited by Telerik Admin]
    Translation from Google Translate:
    "Thank you very much for these tools Fine"
  26. Inge
    Inge avatar
    1 posts
    Member since:
    Oct 2011

    Posted 12 Dec 2011 Link to this post

    Hi Sebastian,

    I'm confused about whether the page index is really retained as you say it is... I agree it would be nice for the same reasons you say (the user wants to see more records beyond the record they are already on) but this is not my experience that it does that. I have a grid with CustomPaging set to true and when the pagesize is changed it always goes back to the first page, which I don't want. I want it to remember the item the user was on and then show the new amount of records on that same page.

    And according to this Telerik example: http://demos.telerik.com/aspnet-ajax/grid/examples/programming/custompaging/defaultvb.aspx it is essentially instructing us to manually handle paging indexes, which seems to contradict your statement (Jan 7th, and Sept.1 2008 of this thread) that it is automatically retained. Am I missing something? Thanks in advance.

  27. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 13 Dec 2011 Link to this post

    Hi Inge,

    As you can see from the following post by my colleague Vlad, the behavior has been changed later on due to a popular demand and the page index is reset by default when the page size is modified. In order to sustain the page index when this happens, you will need to do that manually with code.

    Kind regards,
    Sebastian
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017