[index.cshtml]
<ejs-grid id="Grid" allowPaging="true" load="onLoad" toolbar="@( new List<object>() {"Add","Edit","Delete","Update","Cancel"})">
<e-grid-editsettings allowAdding="true" allowDeleting="true" allowEditing="true"></e-grid-editsettings>
<e-data-manager url="/Index?handler=DataSource" insertUrl="/Index?handler=Insert" updateUrl="/Index?handler=Update" removeUrl="/Index?handler=Delete" adaptor="UrlAdaptor"></e-data-manager>
<e-grid-pageSettings pageCount="5" pageSize="5"></e-grid-pageSettings>
<e-grid-columns>
<e-grid-column field="OrderID" headerText="Order ID" isPrimaryKey="true" textAlign="Right" width="120"></e-grid-column>
<e-grid-column field="CustomerID" headerText="Customer ID" width="150"></e-grid-column>
<e-grid-column field="ShipCity" headerText="ShipCity" textAlign="Right" width="120"></e-grid-column>
</e-grid-columns>
</ejs-grid>
<script>
function onLoad() {
this.dataSource.dataSource.headers = [{ 'XSRF-TOKEN': $("input:hidden[name='__RequestVerificationToken']").val() }];
this.childGrid = {
dataSource: new ej.data.DataManager({
url: "/Index?handler=ChildDataSource",
insertUrl: "/Index?handler=ChildInsert",
updateUrl: "/Index?handler=ChildUpdate",
removeUrl: "/Index?handler=ChildDelete",
adaptor: new ej.data.UrlAdaptor()
}),
queryString: 'EmployeeID',
load: function () {
this.dataSource.dataSource.headers = [{ 'XSRF-TOKEN': $("input:hidden[name='__RequestVerificationToken']").val() }];
},
editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true, mode: 'Normal', showDeleteConfirmDialog: true },
toolbar: ['Add', 'Edit', 'Delete', 'Update', 'Cancel'],
columns: [
{ field: 'orderid', headerText: 'ID', width: 120, visible: true, isIdentity: true, isPrimaryKey: true },
{ field: 'EmployeeID', headerText: 'Employee ID', width: 45, foreignKeyField:"EmployeeID1", foreignKeyValue:"FullName", dataSource:@Html.Raw(Json.Serialize(@ViewData["employeeData"])), visible: true },
{ field: 'FirstName', headerText: 'First Name', width: 75 },
{ field: 'LastName', headerText: 'LastName', width: 45 },
],
};
}
</script>
|
[VrstaObrDop.cshtml]
this.childGrid = {
dataSource: new ej.data.DataManager({
url: "/Placa/PlvrstaObrDopKoef/DataSource",
insertUrl: "/Placa/PlvrstaObrDopKoef/NormalInsert",
updateUrl: "/Placa/PlvrstaObrDopKoef/NormalUpdate",
removeUrl: "/Placa/PlvrstaObrDopKoef/NormalDelete",
adaptor: new ej.data.UrlAdaptor()
}),
queryString: 'VrstaObrDopId',
editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true, mode: 'Normal', showDeleteConfirmDialog: true },
toolbar: ['Add', 'Edit', 'Delete', 'Update', 'Cancel'],
columns: [
{ field: 'RowId', headerText: 'RowId', width: 120, visible: false, isIdentity: true, isPrimaryKey: true },
{ field: 'VrstaObrDopId', headerText: 'VrstaObrDopId', width: 45, visible: true },
{ field: 'DoprinosId', headerText: 'Doprinos', width: 75, foreignKeyValue: 'Sifra', dataSource:@Html.Raw(Json.Serialize(@ViewData["dsDop"]))},
{ field: 'Koeficijent', headerText: 'Koeficijent', width: 45 },
],
actionBegin(args) {
if (args.requestType === 'add') {
args.data.VrstaObrDopId = this.parentDetails.parentKeyFieldValue;
}
} |