要在ASP.NET MVC中使用DataTable显示Filter选项,可以按照以下步骤进行操作:
public class FilterModel
{
public string ColumnName { get; set; }
public string FilterValue { get; set; }
}
public ActionResult GetFilterOptions(string columnName)
{
var options = new List();
var filterValues = db.Table.Select(columnName).Distinct();
foreach (var filterValue in filterValues)
{
options.Add(new SelectListItem
{
Text = filterValue,
Value = filterValue
});
}
return Json(options);
}
Column 1
Column 2
Column 3
@section Scripts {
}