I have a grid I've created in MVC that is throwing the following error when I set the datasource
kendo.all.js:311085 Uncaught TypeError: Cannot read properties of undefined (reading 'id')
Using version 2022.2.802.545
Here is my grid
@(Html.Kendo().Grid<MyModelName>()
.Name("event-violations-grid")
.Columns(columns =>
{
//columns.Select().Width(50);
columns.Bound(s => s.SupplierNumber).Hidden(true);
columns.Bound(s => s.SupplierName).Width(275);
columns.Bound(s => s.OldOrderDate).Format("{0:MM/dd/yyyy}").Hidden(true);
columns.Bound(s => s.OldDeliveryDate).Format("{0:MM/dd/yyyy}").Hidden(true);
columns.Bound(s => s.NewOrderDate).Format("{0:MM/dd/yyyy}").Hidden(true);
columns.Bound(s => s.NewDeliveryDate).Format("{0:MM/dd/yyyy}").Hidden(true);
columns.Bound(s => s.ArrivalDate).Format("{0:MM/dd/yyyy}").Hidden(true);
columns.Bound(s => s.TransmitTime).Hidden(true);
columns.Bound(s => s.ExpectedDeliveryTime).Hidden(true);
columns.Bound(s => s.Action).Width(180);
columns.Bound(s => s.ActionComments);
})
.Sortable()
.Scrollable(s => s.Height("215px"))
.HtmlAttributes(new { style = "height:250px;" })
.Resizable(r => r.Columns(true))
)
(I know there is a lot of hidden columns there.. I may or may not need them yet)
Then I have some javascript which populates a dataSource and sets to this grid
function getViolations() {
var vdata = {};
vdata["stageId"] = _stageId;
vdata["stores"] = "" + _stores.join(',');
vdata["supplierNumber"] = _eventRevertData.SupplierNumber;
vdata["origDeliveryDate"] = kendoDateOnly(_eventRevertData.Start);
vdata["newDeliveryDate"] = null;
var dataSource = new kendo.data.DataSource({
schema: {
model: {
fields: {
SupplierNumber: { type: "number" },
SupplierName: { type: "string" },
OldOrderDate: { type: "date" },
OldDeliveryDate: { type: "date" },
NewOrderDate: { type: "date" },
NewDeliveryDate: { type: "date" },
ArrivalDate: { type: "date" },
TransmitTime: { type: "string" },
ExpectedDeliveryTime: { type: "string" },
OrderGroup1: { type: "boolean" },
OrderGroup2: { type: "boolean" },
OrderGroup3: { type: "boolean" },
OrderGroup4: { type: "boolean" },
OrderGroup5: { type: "boolean" },
OrderGroup6: { type: "boolean" },
OrderGroup7: { type: "boolean" },
OrderGroup8: { type: "boolean" },
Action: { type: "string" },
ActionComments: { type: "string" }
}
}
},
transport: {
read: {
url: "/MyController/GetViolationsGrid1",
data: vdata,
dataType: "json"
}
}
});
dataSource.fetch(function () {
let data = this.data();
console.log(data);
var grid = $("#event-violations-grid").data("kendoGrid");
grid.setDataSource(data);
});
}
This works - my grid displays exactly as I expect, and updates when I call my function (the vdata changes depending on other things)
However, I'm getting this error:
If I open that, I can see that the part of "my" code is here:
Which brings me to here
I have confirmed that I can get as far as line 1228 without issue.. my console.log works and I can see my data.. it seems like it is happening when I'm setting the data source
Any help would be greatly appreciated!
Thanks