[Index.cshtml]
@(Html.EJ().Grid<object>("FlatGrid")
.Datasource(ds => ds.Json((IEnumerable<object>)ViewBag.datasource).UpdateURL("/Grid/Update").
InsertURL("/Grid/Insert").RemoveURL("/Grid/Remove").Adaptor(AdaptorType. RemoteSaveAdaptor)) /* enabling the remote save adaptor */
.AllowPaging() /*Paging Enabled*/
.EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); })
.ToolbarSettings(tool => {
tool.ShowToolbar().ToolbarItems(toolitem =>
{
toolitem.AddTool(ToolBarItems.Add);
toolitem.AddTool(ToolBarItems.Delete);
toolitem.AddTool(ToolBarItems.Edit);
toolitem.AddTool(ToolBarItems.Update);
toolitem.AddTool(ToolBarItems.Cancel);
});
})
.Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add();
-------------
}))
|
[HomeCOntroller.cs]
public ActionResult Update(Orders value)
{
var ds = order.ToList(); //Update the modified record in datasource
Orders result = order.Where(o => o.OrderID == value.OrderID).FirstOrDefault();
if (result != null)
{
result.OrderID = value.OrderID;
result.CustomerID = value.CustomerID;
result.ShipCountry = value.ShipCountry;
result.ShipCity = value.ShipCity;
result.ShipAddress = value.ShipAddress;
}
return Json(value, JsonRequestBehavior.AllowGet);
}
public ActionResult Insert(Orders value)
{
Random ran = new Random();
value.OrderID = ran.Next();// For isIdentity column, need to generate a new value while inserting new record.
order.Insert(0, value); //Add a new record in datasource
return Json(value, JsonRequestBehavior.AllowGet);
}
public ActionResult Delete(int key)
{
Orders result = order.Where(o => o.OrderID == key).FirstOrDefault();
order.Remove(result); //Delete a record in datasource
return Json(key, JsonRequestBehavior.AllowGet);
}
|
The Sample project has a problem we can not add any controller it tell me no model class are availbe
Hi Mortada,
Thanks for the contacting syncfusion forum.
Query: The Sample project has a problem we can not add any controller it tell me no model class are availbe
We checked your query by preparing a sample, but we were unable to replicate the issue at our end.
Please refer to the below sample,
If you still facing issue, please provide the following information
The requested information will be helpful to proceed further
Regards,
Pon selva