This is a migrated thread and some comments may be shown as answers.
Get Grid filtered data
3 Answers 9 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Edwin
Top achievements
Rank 1
Edwin asked on 08 Feb 2013, 08:04 AM
Hi all,

I would like to use the Grid to enable the user to filter the data and after (serverside) filtering, do something with the filtered data.

How can this be done easily? I know Telerik does this by interpreting the postback query-string and building a WHERE clause for SQL for it, but I don't want to do the heavy lifting of the parsing of the where myself.

So I am looking for a way to get the where as an expression (after a grid postback with filtering applied by the user), or simply the complete list of objects that are the result of the filtering. In the latter case, paging must be ignored.

Is this even possible, or do I have to do trickery stuff like breaking into some private Telerik methods that handle the query-string parsing :-)

Kind regards,

   Edwin.

3 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 13 Feb 2013, 08:04 AM
Hello Edwin,

Basically if you are not using client operation mode the filtering by default will be performed on the server. To perform filtering you can use the filter method which the Grid client object provides. 

Another approach would be to perform an ajaxRequest and pass some variable to the action method which then you can use on the server side to perform your own filtering on the collection before passing it to the GridModel.

$('#Grid').data().tGrid.ajaxRequest({myParam:"myValue"})


Kind Regards,
Petur Subev
the Telerik team
Check out the successor of Telerik MVC Extensions - Kendo UI for ASP.NET MVC - and deem it for new ASP.NET MVC development.
0
Edwin
Top achievements
Rank 1
answered on 13 Feb 2013, 08:30 AM
Hello Petur,

Thanks for your reply, but it seems I didn't make myself clear. Let me give an example.

Suppose the user filters the grid by applying a filter on Name, like the name starts with "Bu".
And furthermore, the user orderd by Age.

The resulting URL will be something like:

...?listing-1-page=1&listing-1-orderBy=Age-asc&listing-1-groupBy=~&listing-1-filter=Name~startswith~'Bu'

When the Telerik grid is generated, the grid knows what to do with these query parameters and is able to build an IQueryable with it.

I want to generate this IQueryable without generating the grid, so the user can apply some sorting and filtering and I can perform a bulk action on the exact same data that the user has filtered/sorted in the grid. (I'm not interested in the paging part here).

I hoop I made myself clear now...

Kind regards,

   Edwin.
0
Petur Subev
Telerik team
answered on 18 Feb 2013, 09:33 AM
Hello Edwin,

I am afraid that this is not possible because the collection is actually filtered/paged after the Action method is executed - the GridAction attributes handled this via the OnActionExecuted overriding. 


Kind regards,
Petur Subev
the Telerik team
Check out the successor of Telerik MVC Extensions - Kendo UI for ASP.NET MVC - and deem it for new ASP.NET MVC development.
Tags
Grid
Asked by
Edwin
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Edwin
Top achievements
Rank 1
Share this question
or