I have modified the filter-menu-customization example to perfor server side filtering based on the filter value. I created this action method:
This works fine, but the Bind attribute and the prefix string looks fragile to me. I'm pretty sure there should be a better way to perform the filterValue binding. I imagine there should be a IModelBinder for FIlterDescriptor, so that I could leverage the other aspects of the filter descriptor (starts with, equals, logic operator etc). But I failed to find it.
I posted my example here on Github.
Any suggestions?
public
ActionResult FilterMenuCustomization_Titles([Bind(Prefix=
"filter[filters][0][value]"
)]
string
filterValue)
{
var db =
new
SampleEntities();
var employeeTitles = db.Employees
.Select(e => e.Title)
.Where(t => t.StartsWith(filterValue))
.Distinct();
return
Json(employeeTitles, JsonRequestBehavior.AllowGet);
}
This works fine, but the Bind attribute and the prefix string looks fragile to me. I'm pretty sure there should be a better way to perform the filterValue binding. I imagine there should be a IModelBinder for FIlterDescriptor, so that I could leverage the other aspects of the filter descriptor (starts with, equals, logic operator etc). But I failed to find it.
I posted my example here on Github.
Any suggestions?