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

Using RadGrid with LINQ paging

3 Answers 294 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 15 Aug 2011, 05:50 PM
Hi,
I am trying to use RadGrid with paging, using LINQ for Entities to do paging.  I am using a respository method to do this:

        public IEnumerable<TEntity> GetAllPaged(int page, int pageSize)
        {
            return _objectSet.AsEnumerable().Skip(pageSize).Take(page);
        }

The LINQ part works just fine, but when I do this, the pager on the Grid is no longer available- assuming that all the records are displayed.  Is there anyway to make sure the pager ribbon is still visible, and has the correct number of pages links?  Is there a way to use LINQDataSource (either Microsoft's or Telerik), which makes paging easier and much more efficient?

Thanks,

Steve

3 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 18 Aug 2011, 10:06 AM
Hello Steve,

To achieve your goal you should set the AllowCustomPaging and VistualItemCount properties for the grid. Thus you will achieve the desired custom paging. You can see how this is done in the demo below:
http://demos.telerik.com/aspnet-ajax/grid/examples/programming/custompaging/defaultcs.aspx

Best wishes,
Iana
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Steve
Top achievements
Rank 1
answered on 18 Aug 2011, 03:33 PM
Hi Iana,

It looks fairly simple to implement.  Can I set the VirtualItemCount in code rather than the hard-coded number in the example, such as when I press my search button on the form (and have the criteria set), so that I know the full count of the underlying query? 
0
Iana Tsolova
Telerik team
answered on 19 Aug 2011, 10:13 AM
Hello Steve,

Indeed, you can set the VirtualItemCount in the NeedDataSource event handler.

Kind regards,
Iana
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Grid
Asked by
Steve
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Steve
Top achievements
Rank 1
Share this question
or