I have a grid and the records in it use two fields to make up the primary key. How can I pass both field values to the controller so that I can make sure I delete the correct record? My code is below:
@Html.EJS().Grid("ContainerGrid").DataSource(DataManager => { DataManager.Json(@Model.ContainerTransactions.ToArray()).InsertUrl("Home/AddContainerItem").UpdateUrl("Home/UpdateContainerItem").RemoveUrl("Home/DeleteContainerItem").Adaptor("RemoteSaveAdaptor"); }).Width("auto").Columns(col =>
{
col.Field("InventoryID").HeaderText("Item").IsPrimaryKey(true).Width("40").EditType("dropdownedit").Edit(new { @params = itemDropDown }).ValidationRules(new { required = true }).Add();
col.Field("ContainerID").ValueAccessor(containerAccessor).IsPrimaryKey(true).Visible(false).Add();
col.Field("Description").HeaderText("Description").ValueAccessor(descriptionAccessor).Width("90").Add();
...
}).EditSettings(edit => { edit.AllowAdding(true).AllowEditing(true).AllowDeleting(true).Mode(Syncfusion.EJ2.Grids.EditMode.Dialog); }).Toolbar(new List<string>() { "Add", "Edit","Delete" }).Render()
|
// Grid’s detailDataBound event handler
function onActionBegin(args) {
if (args.requestType === 'delete') {
// Condition executes on performing delete action
this.query = new ej.data.Query().addParams('CustomerID', args.data[0]["CustomerID"]);
}
} |
|
public ActionResult Delete([FromBody]CRUDModel1<OrdersDetails> dm)
{
// The additional value sent in query can be accessed here
var queryValue = dm.CustomerID;
...
}
public class CRUDModel1<OrdersDetails>
{
...
public string CustomerID { get; set; }
} |
How would I pass two parameters?
this.query = new ej.data.Query().addParams('CustomerID', args.data[0]["CustomerID"]);
this.query = new ej.data.Query().addParams('InventoryID', args.data[0]["InventoryID"]);
I figured it out.
this.query = new ej.data.Query().addParams('ContainerID', args.data[0]["ContainerID"]).addParams('CreatedDate', args.data[0]["CreatedDate"]);