Hi Syncfusion!!
I working with Grid (DataTable as Datasource) and i need to perform Editing and then save it into the same Datatable,
My Grid :
@model System.Data.DataTable
@(Html.EJ().Grid<Object>("FlatGrid")
.Datasource((System.Data.DataTable)Model)
.AllowPaging()
.AllowSelection()
.AllowResizeToFit(true)
.AllowScrolling()
.EditSettings(edit => { edit.AllowEditing().EditMode(EditMode.Normal); })
.ToolbarSettings(toolbar =>
{
toolbar.ShowToolbar().ToolbarItems(items =>
{
items.AddTool(ToolBarItems.Edit);
items.AddTool(ToolBarItems.Update);
items.AddTool(ToolBarItems.Cancel);
});
})
.Columns(col =>
{
col.Field("ID").AllowEditing(false).Width(50).IsFrozen(true).IsPrimaryKey(true).Add();
col.Field("VAR1").AllowEditing(false).Width(200).Add();
col.Field("VAR2").AllowEditing(false).Width(100).IsFrozen(true).Add();
col.Field("VAR3").AllowEditing(false).Width(50).Add();
col.Field("VAR4").AllowEditing(false).Add();
col.Field("VAR5").AllowEditing(false).Add();
col.Field("VAR6").AllowEditing(true).EditType(EditingType.String).Add();
})
)
How can i change this to work??
Thanks
O.A
[Index.cshtml]
@(Html.EJ().Grid<object>("Editing")
.Datasource(ds => ds.Json((System.Data.DataTable)ViewBag.dataSource)
.UpdateURL("ExternalUpdate").InsertURL("ExternalInsert").RemoveURL("ExternalDelete")
.Adaptor(AdaptorType.RemoteSaveAdaptor))
.AllowPaging()
----
.Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").IsIdentity(true).IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(90).ValidationRules(v => v.AddRule("required", true).AddRule("number", true)).Add();
-----
})
)
-------------------------------------
[HomeController.cs]
public ActionResult ExternalUpdate(EditableOrder value)
{
//do your stuff here for update a record in database
}
public ActionResult ExternalInsert(EditableOrder value)
{
//do your stuff here for remove a record in database
}
public void ExternalDelete(int key)
{
//do your stuff here for remove a record in database
}
}
|