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

Custom Paging and Filters with SQL Datasource

2 Answers 374 Views
Grid
This is a migrated thread and some comments may be shown as answers.
danparker276
Top achievements
Rank 2
danparker276 asked on 20 Dec 2013, 12:44 AM
Custom paging works great, I have about 400,000 rows, so I just return 100 from sql server when I change pages, using the need_datasource event.  Now it's going to get a bit more complicated when I have 8 different items I can sort or filter.

I basically need to get the filter and convert that filter and sorting into the sql statement that I use to query the database.

I also basically have to make 2 queries to get the VirtualItemCount.

I'm basically doing a  "select ROW_NUMBER() OVER"  to make my row numbers and only getting the range of row numbers I want.  SQL Server 2012 has a fetch(I have 2008) and I saw there's a more effecient way than ROW_NUMBER() OVER, but this is easy for me to manipulate.  My main concern is CPU and memory on the webserver, so getting back just the number of rows in the page is the most important.

I'm guessing this is the best way to do it. (I'm not going to use entity framework).

I think the hard part is me translating the filters and sort orders to my sql statement.  I was wondering if there was an example like this.  No big deal if there isn't, I don't think it will be a big deal to do it, but I was wondering if maybe there was some code out there that already existed.

2 Answers, 1 is accepted

Sort by
0
Accepted
Genady Sergeev
Telerik team
answered on 26 Dec 2013, 08:10 AM
Hello Dan,

Please take a look at the following forum thread that explains how to do it: http://www.telerik.com/community/forums/aspnet-ajax/grid/use-the-radgrid-filter-in-my-own-sql.aspx

You basically should try setting the EnableLinqExpressions property of the grid to false and then take the FilterExpression from the MasterTableView - it should be in a sql format when linq expressions are disabled.

Regards,
Genady Sergeev
Telerik
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 the blog feed now.
0
danparker276
Top achievements
Rank 2
answered on 30 Dec 2013, 06:52 PM
Thanks, yeah it's been working very well like that.
Tags
Grid
Asked by
danparker276
Top achievements
Rank 2
Answers by
Genady Sergeev
Telerik team
danparker276
Top achievements
Rank 2
Share this question
or