Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
146940 | Aug 26,2019 01:29 PM UTC | Sep 3,2019 02:52 PM UTC | ASP.NET Core - EJ 2 | 5 |
![]() |
Tags: DataGrid |
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> |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.