Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
143052 | Mar 1,2019 09:52 PM UTC | Mar 6,2019 03:39 AM UTC | ASP.NET Core - EJ 2 | 1 |
![]() |
Tags: DataGrid |
[index.cshtml]
<ejs-grid id="Grid" dataSource="ViewBag.dataSource" toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" })" allowPaging="true">
<e-grid-pagesettings pageSize="5"></e-grid-pagesettings>
<e-datamanager url="/Home/UrlDatasource" insertUrl="/Home/Insert" updateUrl="/Home/Update" adaptor="UrlAdaptor"></e-datamanager>
<e-grid-editSettings allowAdding="true" allowEditing="true"></e-grid-editSettings>
<e-grid-columns>
. . . .
<e-grid-column field="EmployeeID" headerText="Employee ID" width="110"></e-grid-column>
<e-grid-column field="ShipCountry" valueAccessor="@("shipCountry")" headerText="ShipCountry" edit="@(new {create = "create", read = "read", destroy = "destroy", write = "write"})" width="110"></e-grid-column>
<e-grid-column field="ShipCity" valueAccessor="@("shipCity")" width="110" edit="@(new {create = "createcity", read = "readcity", destroy = "destroycity", write = "writecity"})"> </e-grid-column>
</e-grid-columns>
</ejs-grid>
<script>
function shipCountry(field, data, column) {
var country;
. . . .
data[field] = country;
return country;
}
function shipCity(field, data) {
var city;
. . . .
data[field] = city;
return city;
}
//Remote data
window["shippedData"] = new ej.data.DataManager({
url: 'https://services.odata.org/V4/Northwind/Northwind.svc/Orders/',
adaptor: new ej.data.ODataV4Adaptor,
});
function write(args) {
countryObj = new ej.dropdowns.DropDownList({
dataSource: shippedData, // bind the Remote data
fields: { value: 'EmployeeID', text: 'ShipCountry' },
value: args.rowData['ShipCountry'],
change: function () {
// pass the query from “ShipCountry” to “ShipCity” using foreignKeyValue(“EmployeeID”)
stateObj.enabled = true;
var tempQuery = new ej.data.Query().where('EmployeeID', 'equal', countryObj.value);
stateObj.query = tempQuery;
stateObj.text = null;
stateObj.dataBind();
},
placeholder: 'Select a country',
floatLabelType: 'Never'
});
countryObj.appendTo(countryElem);
};
</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.