Hi Sejal,
Thanks for contacting Syncfusion support.
Based on your query, you want to call the controller side method when you click update command in your grid application. By default, in our EJ2 Grid when you bind remote data using our EJ2 DataManager, we will call the respective UpdateURL method at the controller side to perform the CRUD actions.
However, if you can call the any custom methods at the server side using the commandClick event of the Grid component. Using the command Click event you can call any server-side methods using ajax call. For your convenience, we have attached the code example, please refer them for your reference.
Code Example:
|
@{
List<object> commands = new List<object>();
commands.Add(new { type = "Edit", buttonOption = new { iconCss = "e-icons e-edit", cssClass = "e-flat" } });
commands.Add(new { type = "Delete", buttonOption = new { iconCss = "e-icons e-delete", cssClass = "e-flat" } });
commands.Add(new { type = "Save", buttonOption = new { iconCss = "e-icons e-update", cssClass = "e-flat" } });
commands.Add(new { type = "Cancel", buttonOption = new { iconCss = "e-icons e-cancel-icon", cssClass = "e-flat" } });
}
@Html.EJS().Grid("CommandColumn").DataSource((IEnumerable<object>)ViewBag.DataSource).Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
col.Field("CustomerID").HeaderText("Customer Name").Width("150").Add();
col.HeaderText("Manage Records").Width("160").Commands(commands).Add();
}).AllowPaging().EditSettings(edit => { edit.AllowAdding(true).AllowEditing(true).AllowDeleting(true); }).Render()
<script>
function commandClick(args) {
console.log(args)
// based on the target element call the server side method using ajax here
}
}
</script>
|
UG-Links:
Note: Please refer the above documentation to know more about remote databinding.
Please get back to us if you need further assistance.
Regards,
Ajith G.