Paging in radgrid without having the whole datasource and total rows count

7 posts, 0 answers
  1. tamil
    tamil avatar
    7 posts
    Member since:
    Aug 2010

    Posted 03 Feb 2012 Link to this post

    Hi,
        I have a radgrid in default.aspx page. I want show some data in radgrid with paging. But I dont have the whole datasource at the Need_DataSource event. My backend is like, passing the pagecount and the service will return only 100 records of the Nth page. I dont know the approximate total rows count. How do I achieve paging in radgrid without having the whole datasource and total rows count?
    Please guide me.


    Thanks,
    Tamil
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 03 Feb 2012 Link to this post

    Hello,

    One suggestion is you can use CustomPaging which allows you to fetch only a fixed number of records and perform operations on this limited set of data. Take a look at the following hep documentation which explains more about this.
    Custom Paging.

    -Shinu.
  3. tamil
    tamil avatar
    7 posts
    Member since:
    Aug 2010

    Posted 03 Feb 2012 Link to this post

    Thanks for your reply. How to set the VirtualItemCount. I dont know the approximate total count of my whole datasource. Initially I will be having only a datasource with 100 rows. When clicking on the second page only, I can query the service to return the seconda 100 rows.
  4. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 07 Feb 2012 Link to this post

    Hi,

    You could still set a value for the VirtualItemCount.  If you set a value that is greater than the actual number of items, RadGrid will show all available items plus empty pages (or whatever other content you set) for the items that exceed the actual number.
    For example you have a data source with 9'000 items and you set VirtualItemCount to 10'000. If your page size is 1000, the grid will render 10 pages and the last page will be empty (or with NoRecordsTemplate if you're using such).

    All the best,
    Maria Ilieva
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  5. tamil
    tamil avatar
    7 posts
    Member since:
    Aug 2010

    Posted 07 Feb 2012 Link to this post

    Thanks Maria for your reply. I dont know the items count initially, the count may be less than 100 or greater than 10,000. If I set the value randomly like VirtualItemCount = 10,000, will this affect the performance of the RadGrid?


    Thanks,
    Tamil
  6. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 08 Feb 2012 Link to this post

    Hello.

    Check the following help documentation which explains more about optimizing performance in RadGrid.
    Client/server grid performance optimizations.

    -Shinu.
  7. Sean
    Sean avatar
    21 posts
    Member since:
    Feb 2018

    Posted 07 Dec 2018 Link to this post

    Hello,

    Is there a way to get current DataSource? so i am setting whole list (its not data table or set its a DTO) as data source to grid. If when next page or any paging command is clicked and it needs data source i just want to take current one and give it back to the grid.

    Thank you,

    Sean

Back to Top