How can I solve the Enum filter uing same code but without using ItemTemplate or UI()
/View
columns.Bound(c => c.EmpTypes).Title("Type")
.Filterable(filterable => filterable
.Multi(true)
.ItemTemplate("typetemplate")
.DataSource(ds => ds.Read(r => r.Action("GetEmpTypes", "Report"))));
<script>
function typetemplate(e) {
return ({ Text, Value }) => `<span><label><span>${Text}</span><input type='checkbox' name='" + e.field + "' value='${Value}'/></label></span><br/>`
}
</script>
//ReportController.cs
public JsonResult GetEmpTypes()
{
var enumList = EnumToSelectList(typeof(EmpTypes)); // Convert the Enums to List<SelectListItem>
return Json(enumList, JsonRequestBehavior.AllowGet);
}
public static List<SelectListItem> EnumToSelectList(Type enumType)
{
return Enum
.GetValues(enumType)
.Cast<int>()
.Select(i => new SelectListItem
{
Value = i.ToString(),
Text = Enum.GetName(enumType, i),
})
.ToList();
}