$("#Grid").ejGrid({
allowFiltering:true,
...
columns: [
{
// Field dropdown is an enum field
field: "DropDown", width: 100, filterBarTemplate: {
write: function (args) {
var data = @(Html.Raw(Json.Encode(ViewData["EmployeeID"])));
args.element.ejDropDownList({ width: "100%", dataSource: data, change: ej.proxy(args.column.filterBarTemplate.read, this, args) })
},
read: function (args) {
if (args.element.val() == "clear") {
this.clearFiltering(args.column.field);
args.element.val("")
}
this.filterColumn(args.column.field, "equal", args.element.val(), "and", true)
},
}
},
... ]
});
}); |
create: function(args){
this.element.on("mousedown", ".e-gridheader .e-filtericon", function () {
$("#Grid_stringDlg").ejDialog({
//open event of the filter menu dialog
open: function (e) {
//Disables the operator dropdownlist and equal as default operator such that only discrete values are filtered.
$("#Gridstring_ddinput").ejDropDownList("setSelectedText", "Equal");
$("#Gridstring_ddinput").ejDropDownList("model.enabled", false);
//Enables the 'showPopupButton' to act as dropdownlist
var dp = this.element.find(".e-autocomplete"), instance;
if (dp.length) {
instance = dp.data("ejAutocomplete");
if (!instance.option("model.showPopupButton"))
instance.option("model.showPopupButton", true);
}
}
});
});
},
…….
{ field: "EmployeeID", headerText: "Employee ID", textAlign: ej.TextAlign.Right,type:"string", width: 130 },
|