Kendo UI Grid MVC dataSource.at(0) undefined with AutoBind = false and after dataSource.Read()

crichavin

I have a kendo grid that I don't want to populate on page load, so I have autoBind is set to false. But I also want to make certain columns not editable in certain circumstances. I was following this answer on how to do that, which in short is achieved via:

var $grid = $("#gridName").data("kendoGrid");
$grid.dataSource.at(0).fields["cell"].editable = false;

However, $grid.dataSource.at(0) is undefined if autoBind is false, which I'd expect prior to a dataSource.read(), but not after. So I have this, but $grid.dataSource.at(0) is still undefined and there are several resulting rows in the grid.

var $grid = $("#gridName").data("kendoGrid");
$gridMaterials.dataSource.read();
$grid.dataSource.at(0).fields["cell"].editable = false;

If I change autoBind to true, all works as expected.

How can I achieve setting a column as not editable when not autobinding?

Carsten Franke

The read operation is running asynchronous but your code works sequential. So what happens is that the read operations starts(!) and right after you try to access the (not yet loaded data). You can tell the datasource what should happen once the loading has been finished. See https://docs.telerik.com/kendo-ui/api/javascript/data/datasource/methods/read for an example which uses read's promise functionality.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Kendo Grid datasource refresh does not work in IE

Different Kendo grid Datasource when grouping applied

Error "Uncaught TypeError: Cannot read property '__count' of undefined" in grid datasource

Dynamic bind kendo grid dataSource binded to directive

Kendo Vue datasource for Kendo grid with Auth Header

How can I hide the pager in Kendo UI Grid when autoBind is set to false?

Setting Kendo UI Grid DataSource Read property with Handler in ASP.NET Core MVC with Razor Pages

Kendo UI - JavaScript checkbox value submit to DataSource read

How to filter already filtered datasource in Kendo grid

Kendo grid dataSource.filter all columns

Set datasouce of child grid using datasource of parent grid in Kendo UI

kendo Grid DataSource with OData format = json

How Do I Synch Kendo UI Grid Datasource On Sort?

kendo UI DataSource and complex JSON

How to update and reload the datasource of a Kendo UI MVC grid from clientside upon search

Kendo UI MVC Grid - DataSource Interfering With Column Template

Query Kendo UI DataSource

How to use SignalR Datasource with Kendo Grid

MultiColumn header with Datasource Kendo Grid

Getting Kendo Grid from its DataSource

Get datasource of child grid in Kendo using angular

Kendo UI Grid: I lose pagination after datasource refresh

Unusual Call to Kendo DataSource Read

Kendo Grid MVC - DataSource Error

Kendo UI Grid, sorting datasource groups

kendo grid after resize, reorder, column hide or column show, grid dataSource will be null

how to check if kendo grid datasource is empty

Kendo autocomplete dynamic datasource (AngularJS, kendo ui)

kendo mvc grid with a custom datasource that has null id rows