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

Set filter value before Model Binding of DataSourceRequest

1 Answer 159 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Blake
Top achievements
Rank 1
Blake asked on 03 Aug 2016, 04:57 PM

I have a controller like so: 

1.public async Task<ActionResult> ActionMethod([DataSourceRequest] DataSourceRequest request){...}

When I set a filter on the UI, the controller receives a request object populated with a filter object. 

When I examine the traffic between the client and server I see a string for filter like this:

filter: FirstName~contains~'John'

I imagine there is a Model Binder some where that knows how to instantiate a filter object based on that string.

In this case, the results would be filtered to all entries with a First Name containing John. 

My question is: Is there a way to pass a similar string to the Model Binder from another action? 

For example, 

From another action, I want to create a string like "FirstName~contains~'Mary'" and then Redirect to the "ActionMethod" action pasted above. When the "ActionMethod" is called, I would like the filter object to be constructed so that results would be filtered to all entries with a First Name containing Mary, instead of John. Is this possible? 

 

1 Answer, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 05 Aug 2016, 12:55 PM
Hello Blake,

Basically you can call a ActionMethod is to use RedirectToAction method. Nevertheless, it would be best if you move your code outside the action method such as service. In case you need to filter the datasource then you can add filter expressions on the client which will automatically pass the values to the read method. You can check out the following help article which elaborates more on setting a filter expressions manually. Additionally you can examine this live example as well.

Regards,
Kostadin
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Blake
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Share this question
or