This is a migrated thread and some comments may be shown as answers.

Dynamically change column editability

3 Answers 250 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tom
Top achievements
Rank 1
Tom asked on 22 Apr 2013, 04:50 PM
Hi, I'm trying to change whether a column is read-only based on a code event - but column remains editable. Here is my code:
dataSource.options.schema.model.fields.date.editable = (status === "Paid");

any suggestions?

Regards,
Jack

3 Answers, 1 is accepted

Sort by
0
Tom
Top achievements
Rank 1
answered on 24 Apr 2013, 05:58 AM
I did this in the end by creating two columns, and forking the incoming dataset field during dataSource.parse(). One column is readOnly while the other is editable. 
Does anyone form Telerik have a neater way of doing this - my code attempts have not worked thus far.
Thanks,
Jack
0
Iliana Nikolova
Telerik team
answered on 24 Apr 2013, 11:20 AM
Hi Jack,

I am afraid  changing the columns' editability is not supported in Kendo UI Grid. As a possible workaround you could use the Grid's edit event and close the currently edited cell (depending on your conditions) using the closeCell() method.

Regards,
Iliana Nikolova
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Finys1
Top achievements
Rank 1
answered on 31 Jul 2015, 05:07 PM

I found a solution for this issue, Please guide me if i am wrong

I used the columns editor configuration and looking at options.model.{DataSourceProperty} and appending either an <input> or a <label>

 Code:

fnTestEditor: function (container, options) {
    if (options.model.Status.toLowerCase() !== "valid") $('<input class="k-textbox" data-bind="value:' + options.field + '"/>').appendTo(container);
    else $('<label>' + options.model.{FieldName}+ '</label>').appendTo(container);
}‚Äč

Tags
Grid
Asked by
Tom
Top achievements
Rank 1
Answers by
Tom
Top achievements
Rank 1
Iliana Nikolova
Telerik team
Finys1
Top achievements
Rank 1
Share this question
or