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

Custom Paging, Filtering, and Sorting

4 Answers 288 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 28 Mar 2013, 07:57 PM
I'm dealing with a huge amount of data, so I'm trying to pull back only the data that needs to be shown at that moment.  I'm also trying to make that work with Paging, Filtering, and Sorting (multiple columns).  All of the Grid examples I've seen in the demo focus on one of those things only (if it's a custom implementation).

What I'm hoping to do is have all of the page, filter, and sorting information available to me on any of those events that might fire.  For example if someone adds a filter, and I'm then in the ItemCommand event, I need to see what the current page and page size are, what sorting is currently set, and what other filters are already applied.  From there I can write my own query to the database and get only the data I need.

Is this possible and if so how?  Is there a good example of this I can look at?

Thanks!

Alex

4 Answers, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 02 Apr 2013, 08:41 AM
Hello,

When you are using Sorting, Filtering, Grouping, you should use advanced databinding with NeedDataSource or declarative datasource control. You should not manually bound the control and perform these operation using the DataBind() method.

Keeping this in mind you could check this online demo application which illustrates similar approach.

Greetings,
Andrey
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.
0
Albert Shenker
Top achievements
Rank 1
Veteran
Iron
answered on 25 Dec 2013, 04:18 PM
I don't think the provided demo accomplishes what Alex is after. He is using custom paging which means he is only retrieving those records that are necessary to be displayed. That means he cannot use the built-in filtering to filter records AFTER they are retrieved. Instead, he must pass the filtering info to his Stored Procedure in order to filter the records there. If you look at the custom paging demo you provided and follow these steps, you will see the issue:

1) Sort the "Name" column ascending. You will see there are records that start with "bos".

2) Sort the "Name" column descending.

3) Now apply a filter to the name column of "Starts With" "bos". You will get no results, when obviously there are records in the database which match this filter.

What the demo is doing is retrieving the first page of records sorted descending by "Name" and then applying the filter, so the "bos" records do not exist in the data that is bound to the grid.

What Alex needs to do, and what anyone needs to do when they use custom paging is pass all the relevant sorting, paging and filter information to their SP so the data is filtered prior to retrieval. An online example of accomplishing this for multiple filtered and sorted columns would be nice.
0
Alex
Top achievements
Rank 1
answered on 26 Dec 2013, 02:13 PM
Yes, that is what I ended up with.  I just gathered all of the paging, sorting, filtering information and used it in the SP for data retrieval.  I had to look around for how to accesss each of those things individually, as there was no unified documentation that said how to get all this info.  No documentation that addresses "So you want to use paging, filtering, and sorting on a need-to-show basis?".  So one page laying this out might be useful.
0
Angel Petrov
Telerik team
answered on 30 Dec 2013, 01:48 PM
Hello Alex,

I am glad to hear that you were able to resolve the issue. Regarding the documentation you can find helpful information on the sort and filter expressions here and here. Additionally you may also examine our Custom paging help article.

Note that there is no complete example which demonstrates a possible realization as such type of scenarios are defined as custom. The online documentation focuses on the built-in functionality of the control and does not illustrate complex scenarios like the described.

Regards,
Angel Petrov
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.
Tags
Grid
Asked by
Alex
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Albert Shenker
Top achievements
Rank 1
Veteran
Iron
Alex
Top achievements
Rank 1
Angel Petrov
Telerik team
Share this question
or