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

[Solved] Leverage Filtering Libraries?

3 Answers 87 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
sL342799
Top achievements
Rank 1
sL342799 asked on 31 Aug 2011, 04:23 AM
Hi There!

Just wanted to say how impressed I am with your support and toolset!

I have the following scenario I need some help with:

- I am using an ajax enabled grid to query records from my database;
- User's are able to filter various columns using the built in grid filtering features;
- User's can filter the grid contents by selecting a series of hyperlinks (represent various record counts) which pass a "queryType" parameter to grid.rebind(). This causes my ajax to kick in, and a "filtered" result is passed back; At this point Telerik "magically" applies any filter's the user has specified (I am not sure how this actually occurs, but I suspect it happens as part of the GridAction attribute added to the top of my Ajax call).

The record counts noted above do not reflect any of the filtering that get's applied. One way I am thinking of solving this is to call a javascript/jquery method once the ajax returns and pass the grid.FilterBy parameter. However I do not want to *even try* to recreate the brilliant logic you've already built to parse the filterBy screen and filter records... is there an elegant way to leverage the filterBy parameters to "filter" my count query in the respective Linq2SQL call? or maybe an explanation on how you filter the query results without going back to the database (I'm assuming this is what you are doing)...

Hope this makes sense

D.

3 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 31 Aug 2011, 09:25 AM
Hi Sl342799,

Thank you for the nice words!

Could you please clarify what you mean by "record counts"? The grid should properly update the total number of records being displayed when you use the filtering.

The grid keeps the currently applied filters and sends them to the server action method. Indeed the GridActionAttribute is responsible for translating those filters to LINQ expression and applying them to the datasource (prefiltered or not) which you provide via GridModel.

Regards,
Atanas Korchev
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
sL342799
Top achievements
Rank 1
answered on 31 Aug 2011, 01:58 PM
Thanks Atanas,

Sorry I should have been more clear. I have a "dashboard" of various hyperlinks that represent the counts of records in various states in the database. For example "New - 50", "In Progress - 25", "Closed - 20". Each of those is a hyperlink which passes a querytype to grid.rebind (e.g. grid.rebind("new");). This then filters all the records in the grid, showing only those that are "New".

When a user filters the grid (e.g. selects records between dates), I'd like to update my dashboard counts to reflect the selected filters. In this case I need access to the filters and need to apply them to my linq2sql queries which generate the original counts.

I do not want to put the status column into the grid for other reasons...

Thanks!
0
Atanas Korchev
Telerik team
answered on 01 Sep 2011, 08:07 AM
Hi Sl342799,

 Perhaps you can use the total field of the grid in this case? It shows how many items the datasource has:

var grid = $("#Grid").data("tGrid");
var total = grid.total;

I suppose you can use that value to update the text of your links.

All the best,
Atanas Korchev
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
Grid
Asked by
sL342799
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
sL342799
Top achievements
Rank 1
Share this question
or