Set filter value before Model Binding of DataSourceRequest

2 posts, 0 answers
  1. Blake
    Blake avatar
    2 posts
    Member since:
    Nov 2015

    Posted 03 Aug Link to this post

    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? 


  2. Kostadin
    Kostadin avatar
    1687 posts

    Posted 05 Aug Link to this post

    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.

    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
  3. UI for ASP.NET AJAX banner
Back to Top