i am trying to implement a generic column filter based on the link (https://www.echosteg.com/jquery-datatables-asp.net-mvc5-server-side")
for exemple in the controller we would like to filter i have this method
public Dictionary<string,string> ColumnRequestAangifte()
{
var _IDCOLUMN = Request.Form.GetValues("columns[0][search][value]").FirstOrDefault();
columnName.Add("_IDCOLUMN", _IDCOLUMN);
var VAL_IDCOLUMN = Request.Form.GetValues("columns[1][search][value]").FirstOrDefault();
columnName.Add("VAL_IDCOLUMN", EVAL_IDCOLUMN);
}
used to give parmeter to the filter controller dictColumns my problems how to i know the miscellenous property of p as p is coming from v and v is Generic list
public class FilterController : Controller
{
// GET: Filter
public IQueryable<T> FilterList<T>(Dictionary<string,string> dictColumns)
{
List<T> v = new List<T>();
var search = Request.Form.GetValues("search[value]").FirstOrDefault();
int count = 0;
var results = v.AsQueryable();
foreach (KeyValuePair<string,string> item in dictColumns)
{
var t = item.Key;
t = Request.Form.GetValues("columns["+count+"][search][value]").FirstOrDefault();
count++;
results = results.Where
(
//p.? this is where i ma struggling
p => (search == null || (p. != 0 && p..ToString().ToLower().Contains(search.ToLower())))
&& (t == null || (p. != 0 && p..ToString().ToLower().Contains(t.ToLower())))
);
}
return results;
}
}
}
Aucun commentaire:
Enregistrer un commentaire