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

[Solved] Add FilterDescriptors to Grid when Initializing

5 Answers 105 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.
mike
Top achievements
Rank 1
mike asked on 18 Jan 2012, 06:22 PM
I have a Grid that I am trying to pass filterdescriptors to when the page loads. The initial load is server side, then the subsequent loads will be ajax requests. 

My Model contains a GridCommand Property, I just don't know how to set the Filters on the view based on the filterdescriptors in the GridCommand.

Has anyone done this?

5 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 23 Jan 2012, 09:13 AM
Hi,

You should be able to access the filter descriptors in the view and then configure the grid. How to enumerate the filter descriptors is shown in our custom binding demo (check the BindingHelper tab and the ApplyFiltering method).

Regards,
Atanas Korchev
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 Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
mike
Top achievements
Rank 1
answered on 23 Jan 2012, 04:01 PM
Atanas,

I would like to do add a the filter descriptors that I set on my Model in the controller for the view so that they are initially set on grid.

.Filterable(filtering => filtering.Filters(filters =>
           filters.AddRange(_model.MyBuGridCommand.FilterDescriptors)))

Something like the above example.
0
Atanas Korchev
Telerik team
answered on 23 Jan 2012, 04:25 PM
Hi,

Unfortunately I have misunderstood your requirements and have mislead you with my previous reply. Please accept my apologies for that.

Currently there is no AddRange method and setting the filter requires an expression e.g.

filters.Add(o => o.ContactName).StartsWith("Paul");

There is a protected collection of FilterDescriptors however which perhaps can be used if made public. Would you like to try a build where this property is exposed so you can set it?

Regards,

Atanas Korchev
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 Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
mike
Top achievements
Rank 1
answered on 23 Jan 2012, 04:30 PM
Sure that would be great to have that as public.
0
mike
Top achievements
Rank 1
answered on 24 Jan 2012, 06:14 PM
Atanas, did you find the solution to make the filters public? I changed the properties and tried to set like the following:

.Filterable(filtering =>  new GridFilteringSettings(){Enabled=true, Filters =  Model.MyBuGridCommand.FilterDescriptors} )


The problem I'm running into is that the Filters on a GridCommand are
IList<IFilterDescriptor> and the Filters on the GridFilteringSettings are 
List<CompositeFilterDescriptor>. Is there an internal method that will have the grid accept an Ilist
of IFilterDescriptors? I imagine this would be
similar to when you apply a filter manually during initializing.


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