Hi Malcolm,
Thanks for contacting Syncfusion support.
Query: “Is there a way to persist the reordering that is done on the browser side to the DB?”
We can achieve your requirement using the RowDropMapper property of RowDropSettings of Grid. By using the RowDropMapper property, we can obtain the row data which is reordered and the destination row index. Please refer the below code example and screenshots for your reference.
|
@(Html.EJ().Grid<OrdersView>("Grid")
.Datasource(ds => ds.Json((IEnumerable<object>)ViewBag.datasource).Adaptor(AdaptorType.RemoteSaveAdaptor))
.AllowSorting()
.AllowPaging()
.SelectionType(SelectionType.Multiple)
.AllowRowDragAndDrop()
.RowDropSettings(drop => drop.RowDropMapper("/Home/RowDropHandler"))
.Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(55).Add();
col.Field("CustomerID").HeaderText("Customer ID").Width(70).Add();
col.Field("EmployeeID").HeaderText("Employee ID").TextAlign(TextAlign.Right).Width(70).Add();
col.Field("Freight").HeaderText("Freight").TextAlign(TextAlign.Right).Width(55).Add();
})
)
[controller]
public ActionResult RowDropHandler(List<EditableOrder> changed, List<EditableOrder> added, List<EditableOrder> deleted)
{
JavaScriptSerializer ser = new JavaScriptSerializer();
RowDropModel dropDetails = (RowDropModel)ser.Deserialize(Request.Headers["rowDropDetails"], typeof(RowDropModel));
///// You can perform the required operations here.
return Json("success", JsonRequestBehavior.AllowGet);
} |
Please refer the below screenshots.
- Data of the row which is reordered.
- Destination index.
Please refer the below link for the sample.
Refer our help documentation from below link
please get back to us if you have further queries.
Regards,
Vignesh Natarajan