Store Filtering and Sorting Values to reproduce Query

Sep 3, 2013 at 3:45 PM
Hello Again Guys,

I want to know how can i access filters and sorting values and store them so i can reproduce the same query on db context. So far the only place I've found those values is in the url of the grid. is there any other place or local variable from which i can take them?

I would like to pass them to a function on the controller through a post method, after that reproduce the query from db context and export that set of values using an excel library.

Thanks in advance, Any results of my work I plan on sharing the code so other could do the same because I see is a recurring question how to export data from the grid to excel.
Sep 4, 2013 at 3:50 PM

If you wat to use built-in functionality of filtering, sorting you need to provide IQueryable collection and the grid will produce query to database, according picked filter and sorting settings. By default grid uses filter and sorting settings that passed from URL (in query string).
Sep 4, 2013 at 7:17 PM
Yes I'am using the built in functionality, but i wish to know if there is a place where the grid stores the filter settings other than the url so i can take those settings, make a db query ( just like the grid does) and export all those values. What I mean is there something like:

pageGrids.MYGRIDSNAME.column(MYCOLUMNAME).Filter = EqualsTo

pageGrids.MYGRIDSNAME.column(MYCOLUMNAME).Filter.Value = XXX

where i can take the settings to reproduce the grid query

so i can do like
                        var FilteredOrders = from u in context.Orders
                                                       where u.Number.EqualsTo("XXX")
                                                       select u;
them take FilteredOrders (Which are the same records the grid got from db) and export them using a excel library (which i already know how to do)

Or do i have to Parse it from the url if i wish to get the filter settings and values?
Sep 5, 2013 at 3:09 AM
You can access to current filter settings from Grid.Settings.FilterSettings.
Since 3.0 version filtersettings api changed. because the grid now support multiple filter settings