We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Issue Related to Grid

hello,
i want to Edit selected row content in Syncfusion grid (razor view).
hpw i can do this. can you provide a information about it or sample example


1 Reply

ES Eswari S Syncfusion Team September 20, 2011 11:31 AM UTC

Hi Shivkumar,

We have prepared the sample for grid editing and the same can be downloaded from the following link :

Sample-439078139.zip

Steps to check with the sample :

Step #1 : Specify the GridEditing mode through the EditMode

@{ Html.Syncfusion().Grid("SampleGrid")
. . . .

.Mappers(map=>{
map.InsertAction("AddOrder")
.SaveAction("OrderSave")
.DeleteAction("DeleteOrder"); // action mappers for editing operations

})
.ToolBar(tools =>
{
tools.Add(GridToolBarItems.AddNew)
.Add(GridToolBarItems.Edit)
.Add(GridToolBarItems.Delete)
.Add(GridToolBarItems.Update)
.Add(GridToolBarItems.Cancel); // toolbar items

})
.Editing(edit =>
{
edit.AllowEdit(true) // set allow edit as true
.AllowNew(true)
.AllowDelete(true);
edit.EditMode(GridEditMode.Normal); //specify the EditMode
edit.PrimaryKey(key => key.Add(p => p.OrderID)); // OrderID is the primary key

})
.Render();
}


Step #2 : [Controller]


[AcceptVerbs(HttpVerbs.Post)]

public ActionResult OrderSave(EditableOrder ord) // action for record saving
{
OrderRepository.Update(ord);

var data = OrderRepository.GetAllRecords();

return data.GridActions();

}

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult AddOrder(EditableOrder ord) // action for adding records
{
OrderRepository.Add(ord);

var data = OrderRepository.GetAllRecords();

return data.GridActions();

}

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult DeleteOrder(int OrderID) // action for deleting records
{

OrderRepository.Delete(OrderID);

var data = OrderRepository.GetAllRecords();

return data.GridActions();

}

St Step #3: Add the MicrosoftMvcValidation.debug.js file in the Layout.cshtml page.

. . .






Step #4: Add the following script files when the UnobtrusiveJavaScriptEnabled is true in web.config file.

[Web.config]



. . .
// if it is true ,add the following script files


[_Layout.cshtml]

. . . .
. . . .






Currently ,we don’t have the UG document for Razor. Shortly ,we will the update it in online. For the meantime ,we would suggest you to refer to the following UG link:

http://help.syncfusion.com/ug_93/User%20Interface/ASP.NET%20MVC/Grid/default.htm?turl=Documents%2F5711throughgridbuilder.htm

Please try this and let us know if you need any further assistance.

Regards,
Eswari.S





Loader.
Live Chat Icon For mobile
Up arrow icon