When I click my (test) button to select a row (with Id = 2) in my grid, I get the error:
"Uncaught TypeError: Cannot read properties of undefined (reading 'get') at selectRowById".
Here is my function:
function selectRowById(id) {
var grid = $("#grid").data("kendoGrid")
var dataItem = grid.dataSource.get(id);
var dataItemUID = dataItem.get("uid");
var tableRow = $("[data-uid='" + dataItemUID + "']");
grid.select(tableRow);
}
Here is my grid:
@(Html.Kendo().Grid<Document>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(p => p.DocumentId).Title("Doc Id").Filterable(false).Width(90);
columns.Bound(p => p.StorageContainer).Title("Container").Width(100);
columns.Bound(p => p.FileName).Width(350);
columns.Bound(p => p.DocStatus).Width(125);
columns.Bound(p => p.FileSize).Width(125).HtmlAttributes(new { @style = "text-align: right" });
columns.Bound(p => p.ClientDocumentId).Title("Client Doc Id").Width(200);
columns.Bound(p => p.CreateDate).Format("{0:MM/dd/yyyy}").Width(130);
columns.Command(command => { command.Edit().Text(" "); command.Destroy().Text(" "); }).Width(150);
})
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Selectable(selectable => selectable
.Mode(GridSelectionMode.Multiple)
.Type(GridSelectionType.Row))
.Pageable()
.Resizable(resize => resize.Columns(true))
.Pageable()
.Sortable()
.Scrollable()
.Reorderable(reorder => reorder.Columns(true))
.Filterable()
//.Groupable()
.HtmlAttributes(new { style = "height:650px;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Model(model =>
{
model.Id(p => p.DocumentId);
model.Field(p => p.DocumentId).Editable(false);
model.Field(p => p.CreateDate).Editable(false);
})
.Read(read => read.Action("Read", "Document").Data("getApplicationId"))
.Create(update => update.Action("Create", "Document"))
.Update(update => update.Action("Update", "Document"))
.Destroy(update => update.Action("Delete", "Document"))
)
)
Any help would be greatly appreciated. Thanks.
Mark