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?
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.
Comments