I want to make a KendoUI Grid column programmatically non editable.
The information which column should be non editable, I will get after the grid was created and filled with data in my application. Thats why I have to set it programmatically.
First I created the grid on this way:
var dataSource = new kendo.data.DataSource({
schema: {
model: {
fields: {
field1: {
editable: true,
},
field2: {
editable: true,
}
}
}
}
});
$(domNode).kendoGrid({
editable: true,
dataSource: dataSource,
columns: [{
field: 'field1',
title: 'First column'
},
{
field: 'field2',
title: 'Second column'
}
]
});
Then I add some data (I know its not realy necessary to show this here):
var grid = $(domNode).data('kendoGrid');
grid.dataSource.add({
field1: 'Some value',
field2: 'Some other value'
});
Later in my application, I will get the information which column should be non editable. Then I've tried the following:
grid.dataSource.options.schema.model.fields['field1'].editable = false;
grid.dataSource.read(); // No changes, cloumn is still editable
grid.refresh(); // No changes, cloumn is still editable
grid.setDataSouce(grid.dataSouce); // No changes, cloumn is still editable
I'm desperately. Whats the correct way to porogrammaticly make a column non editable?