I've achieved sorting in Filter Multi-Select Checkboxes but I'm thinking I may be making it harder than it has to be.
The simpler code shown here provides multi-select checkboxes, but they're not sorted into order.
.Filterable(ftb => ftb.Multi(
true
).Search(
true
));
Adding a data source enables us to sort each checkbox list into proper order.
.Filterable(ftb => ftb.Multi(
true
).Search(
true
).DataSource(ds => ds.Read(r => r.Action(
"filterPOD"
,
"Home"
).Data(
"{ field: 'PODNumber' }"
))))
But this requires me to have a corresponding block of code in my controller for EACH column that I intend to filter with Multi-select CBs.
public
ActionResult filterPOD(
string
field)
{
var w =
new
SQL_DB_Entities();
var result = w.Shipping_Table.Select(x =>
new
filterModel
{
PODNumber = x.PODNumber
}).Distinct().OrderBy(p => p.PODNumber);
return
Json(result, JsonRequestBehavior.AllowGet);
}
It's probably something simple I'm overlooking, but I'd like to create a block of "Generic" code in my controller to return the sorted lists needed for multi select checkboxes, rather than having to repeat this block of code for each fieldname / column that I filter. I'm already passing the field name as a string (named "field"). How can I replace the 3 instances of "PODNumber" in this block of code to use the value of the field variable instead so that I can have a single generic block of code? That would be a more elegant solution than the "brute force" one of repeating this code over and over. I'm new to MVC and jquery, so please be gentle with me. -Darron