@(Html.EJ().Grid<object>("Grid")
.Datasource(d => d.URL("/Home/DataSource").UpdateURL("/Home/CellEditUpdate").InsertURL("/Home/CellEditInsert").RemoveURL("/Home/CellEditDelete").Adaptor(AdaptorType.UrlAdaptor))
.EnableAltRow()
.EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing().EditMode(EditMode.Dialog); })
.AllowPaging()
.Query("ej.Query().addParams('selectedGroup','0')")
.AllowFiltering()
.FilterSettings(fil=>fil.FilterType(FilterType.Menu))
..
.Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).ValidationRules(v => v.AddRule("required", true).AddRule("number", true)).Width(90).Add();
col.Field("CustomerID").HeaderText("Customer ID").Width(90).ValidationRules(v => v.AddRule("required", true).AddRule("minlength", 3)).Add();
col.Field("Freight").HeaderText("Freight").TextAlign(TextAlign.Right).Width(75).EditType(EditingType.Numeric).Format("{0:C}").NumericEditOptions(new EditorProperties() { DecimalPlaces = 2 }).ValidationRules(v => v.AddRule("range", "[0,1000]")).Add();
col.Field("ShipCity").HeaderText("Ship City").Width(90).Add();
})
.ClientSideEvents(eve => { eve.ActionBegin("begin").DataBound("databound").EndEdit("endEdit").EndAdd("endEdit"); })
)
<script type="text/javascript">
function databound(args) {
this.element.on("mousedown", ".e-gridheader .e-filtericon", function () {
$("#Grid_stringDlg").ejDialog({
//open event of the filter menu dialog
open: function (e) {
var dp = this.element.find(".e-autocomplete"), instance;
var query = ej.Query().addParams('selectedGroup', '0');
if (dp.length) {
instance = dp.data("ejAutocomplete");
instance.model.query = query;
}
}
});
});
}
</script> |