Hi Sulthana,
Thank you for your reply,.Columns(col =>
{
col.Type("checkbox").Width(50).Add();
col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).ValidationRules(v => v.AddRule("required",true).AddRule("number", true)).Width(100).Add();
col.Field("Freight").HeaderText("Freight").Format("{0:c2}").Width(100).Add();
col.Field("OrderDate").HeaderText("Order Date").Format("{0:MMM dd,yyyy}").Width(100).Add();
col.Field("ShipAddress").HeaderText("Ship Country").EditType(EditingType.Dropdown).Width(100).Add();
})
Best regards
ALJANE
Client side:-
@(Html.EJ().Grid<object>("FlatGrid")
.Datasource((System.Data.DataTable)Model)
.AllowPaging()
.EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); })
.ClientSideEvents(eve => { eve.DataBound("dataBound"); })
.Columns(col =>
{
foreach (System.Data.DataColumn column in Model.Columns)
{
col.Field(column.ColumnName).Width(100).Add();
}
})
)
<script type="text/javascript">
function dataBound(args) {
var column = this.getColumnByIndex(1);
column.isPrimaryKey = true;
//Here columns method used to update the particular column
this.columns(column, "update");
}
</script>
|