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

Custom Filter

3 Answers 266 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Manuel
Top achievements
Rank 1
Manuel asked on 04 Jun 2009, 05:09 PM
Hi, I have a question...
I'm using ADO Entity FrameWork and displays information in a GridView, all filters work correctly...
When I get the information with the Entity Framework, I put a top... I mean, if i have 50 records in a table, only I get 20.
Code:
var table = Context.Table.Top(20);
GridView1.DataSource = table;

I want to do is put other filter options (custom filter) in the menu of filters to obtain the others 30 records. I mean, how can I put other options in the menu filter and specify my own code to make another type of filter?

because The default filters only filter the records displayed.

my apologies for my english I hope to have explained..
Thanks!!

3 Answers, 1 is accepted

Sort by
0
erwin
Top achievements
Rank 1
Veteran
Iron
answered on 04 Jun 2009, 10:45 PM

The grid view filters filter only on the data that you have already loaded into the grid.

You could probably extend the functionality, but writing the
correct database query to reflect all possible filter combinations on several columns is not trivial.

There is virtual mode which allows you to implement a paging algorithm to retrieve data in chunks, but that is also not trivial to implement correctly.

Unless you have huge tables, or network constraints it's IMHO best to tune the SQL that loads the data as possible and load all rows in one go into the grid. I routinely do that with tables that consist of a couple of thousand rows.

Best wishes
Erwin
0
Manuel
Top achievements
Rank 1
answered on 05 Jun 2009, 04:00 PM
Thank you Erwin!!
but my problem is that my database is very large, holds up to millions of records...
then I want to show only a few records, and when I make a filter that is about all that are in the database, not just those shown...

that's why I want to know just how to put another option in the menu Filter?
and that option I change the DataSource of the GridView with the new information to show.

Or another solution would be an event before applying the filter, so I can change the way of filtering

thanks!!
0
erwin
Top achievements
Rank 1
Veteran
Iron
answered on 05 Jun 2009, 04:46 PM
Manuel,

In my app, I keep selection criteria from the DB stricty separate from the grid filters, so that the user is aware if she loads data from the DB or merely filters data that's already loaded.

One reason for this is, that the filtering of the grid evolves with every telerik release and I don't want to interfere with that. If telerik decides to add a new cool filter feature to the grid, I just compile with the new version and hope that I get the functionality for free ;-). Vice versa, if users demand a new filter for loading data from the db (which is often not simply a filter on a column but a complex condition involving other tables etc.) I can implement this with no worries of breaking anything in the GridView.

So I end up with most windows having 2 parts, a panel on top where the user can define database selection criteria and the grid below with filtering enabled. So far, the users had no problem understanding these two different mechanisms. There are more usability problems with the grid's filtering UI which is not very intuitive. For example, it's sometimes hard to tell if a filter is active or not - especially with boolean columns.

Therefore, I also added visual clues to indicate that any grid filtering is active, display the total of rows read from the DB, versus "visible" rows in the grid and finally provided a context menu to clear all filters.

I think the filtering mechanisms of the grid are currently not designed with custom extensibility in mind. But maybe someone from telerik has a different opinion.

Good luck!

Erwin


Tags
GridView
Asked by
Manuel
Top achievements
Rank 1
Answers by
erwin
Top achievements
Rank 1
Veteran
Iron
Manuel
Top achievements
Rank 1
Share this question
or