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

Autocomplete MVC Action Filter Paramater

1 Answer 44 Views
AutoComplete
This is a migrated thread and some comments may be shown as answers.
Scott Rakestraw
Top achievements
Rank 1
Scott Rakestraw asked on 08 Dec 2011, 03:15 AM
When calling an action, what is the best way to access the filter value?  The code below works but know there must be a better way.

 
public JsonResult Autocomplete(int take, int skip, int page, int pageSize)
       {
            
           string filter = Request.QueryString["filter[filters][0][value]"].ToString();
 
           IEnumerable<SearchEntity> searchresults = searchRepository.NameSearch(filter, take, URLType.App).ToList();
 
           var serializer = new JavaScriptSerializer();
           var serialized = serializer.Serialize(searchresults);
 
           return Json(searchresults, JsonRequestBehavior.AllowGet);
       }

1 Answer, 1 is accepted

Sort by
0
Scott Rakestraw
Top achievements
Rank 1
answered on 08 Dec 2011, 03:23 AM
I did discover I can just pass specific values, which also works.

read: ...,
    parameterMap: function(options)  {
        if (options.filter) {
            return "text=" + options.filter.filters[0].value;
        }
    }
Tags
AutoComplete
Asked by
Scott Rakestraw
Top achievements
Rank 1
Answers by
Scott Rakestraw
Top achievements
Rank 1
Share this question
or