@(Html.EJ().Grid<object>("FlatGrid")
.Datasource(ds => ds.Json((IEnumerable<object>)ViewBag.dataSource).UpdateURL("NormalUpdate").InsertURL("NormalInsert").RemoveURL("NormalDelete").Adaptor(AdaptorType.RemoteSaveAdaptor))
.EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); })
---------------------------------------------
.IsResponsive()
.EnableResponsiveRow()
.Columns(col =>
{
col.Field("CustomerID").HeaderText("Customer ID").EditTemplate(a => { a.Create("create").Read("read").Write("write"); }).TextAlign(TextAlign.Right).Width(90).Add();
col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(100).ValidationRules(v => v.AddRule("required", true).AddRule("minlength", 3)).Add();
col.Field("ShipCity").HeaderText("Ship City").TextAlign(TextAlign.Right).Priority(2).EditType(EditingType.Dropdown).Width(80).ValidationRules(v => v.AddRule("required", true)).Add();
col.Field("Freight").HeaderText("Freight").TextAlign(TextAlign.Right).Width(80).Priority(3).EditType(EditingType.Numeric).Format("{0:C}").ValidationRules(v => v.AddRule("range", "[0,10000]").AddRule("required", true)).Add();
col.Field("EmployeeID").HeaderText("Employee ID").Priority(4).Add();
col.Field("District").Visible(false).Add();
-------------------------------------
})
.ClientSideEvents(eve => { eve.ActionComplete("beginEdit"); })
)
-----------------------------------------
var db = $("#FlatGrid").ejGrid("option", "dataSource");
var states = [
{ index: "s1", DisplayName: "VINET" }, { index: "s2", DisplayName: "TOMSP" },
{ index: "s3", DisplayName: "HANAR" }, { index: "s4", DisplayName: "VICTE" },
{ index: "s5", DisplayName: "SUPRD" }, { index: "s6", DisplayName: "CHOPS" },
{ index: "s7", DisplayName: "RICSU" },
{ index: "s8", DisplayName: "WELLI" },
{ index: "s9", DisplayName: "HILAA" },
];
$("#FlatGridCustomerID").ejAutocomplete(
{
dataSource: states,
fields: { text: "DisplayName", key: "Territory" },
select: function (argument) {
var territory = argument.key;
//Update the funding drop down with the correct funding types for the entered rep
}
});
//Disable the fields for host rep
if (args.requestType == "beginedit") {
var data = args.row.find("input");
for (var i = 0 ; i < data.length ; i++) {
if (data[i].name == "EmployeeID" && parseInt($(data[i]).attr("value")) == 1) {
$(data[i]).addClass("e-disable").attr("disabled", "disabled");
}
}
}
} |