Index.cshtml
@{
ViewData["Title"] = "Home Page";
}
@{
var dataM = new Syncfusion.EJ2.DataManager()
{
Url = "/Home/UrlDataSource1",
Adaptor = "UrlAdaptor"
};
}
<ejs-grid id="Grid" toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update" })" actionBegin="actionBegin">
<e-data-manager url="/Home/UrlDataSource" adaptor="UrlAdaptor" insertUrl="/Home/Insert" updateUrl="/Home/Update" removeUrl="/Home/Remove"></e-data-manager>
<e-grid-editSettings allowAdding="true" allowDeleting="true" allowEditing="true" mode="Normal"></e-grid-editSettings>
<e-grid-columns>
<e-grid-column field="OrderID" headerText="Order ID" isPrimaryKey="true" textAlign="Right" width="100"></e-grid-column>
<e-grid-column field="CustomerID" headerText="Customer ID" type="string" width="120" foreignKeyValue='Country' dataSource="dataM"></e-grid-column>
<e-grid-column field="Freight" headerText="Freight" textAlign="Right" format="C2" editType="numericedit" width="120"></e-grid-column>
<e-grid-column field="ShipCountry" headerText="Ship Country" width="150" editType='dropdownedit'></e-grid-column>
</e-grid-columns>
</ejs-grid>
<script>
function actionBegin(args) {
if (args.requestType === 'add' || args.requestType === 'beginEdit') {
this.columns[1].edit.params.query.params = [];
this.columns[1].edit.params.query.addParams('extraParams', args.rowData.OrderID); //adding params for each row through editparams of the dropdownlist
}
}
</script> |
Controller
public IActionResult UrlDatasource1([FromBody]ExtendDataManager dm)
{
var param = dm.extraParams;
// here you can get the params for each row while editing
. . .
} |
Index.cshtml
@{
ViewData["Title"] = "Home Page";
}
@{
. . .
Object ShipCountryvalueAccess;
ShipCountryvalueAccess = "ShipCountryvalueAccessFn";
}
<ejs-grid id="Grid" toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update" })">
<e-data-manager url="/Home/UrlDataSource" adaptor="UrlAdaptor" insertUrl="/Home/Insert" updateUrl="/Home/Update" removeUrl="/Home/Remove"></e-data-manager>
. . .
<e-grid-column field="ShipCountry" headerText="Ship Country" valueAccessor="ShipCountryvalueAccess" width="150" editType='dropdownedit'></e-grid-column>
</e-grid-columns>
</ejs-grid>
<script>
function ShipCountryvalueAccessFn(field, data, column) {
// based on the data and field you can customize and display the values.
return data[field];
}
</script> |
Hi,
Is this functionality still available? I tried it, but as soon I start editing, the DataManger is refreshed without the 'extraParams'. Do I miss something?
Hi Lucian,
Greetings from Syncfusion support.
Thank you for reaching out to us with your inquiry. We understand that you need assistance in resolving an issue you are facing with our grid. To provide an accurate and effective solution, we kindly ask that you provide us with the following information:
Complete grid rendering code.
A Simple sample that demonstrates the issue you are experiencing.
A video demo of the requirement.
Syncfusion package version you are using.
This will enable us to fully understand the problem and provide you with the best possible solution.
Regards,
Joseph I.