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

Controlling column readonly attribute with Javascript

2 Answers 122 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
German
Top achievements
Rank 1
German asked on 03 May 2012, 02:38 PM
Hi, What would be the correct approach to control readonly attribute with Javascript? I actually have an Option group that define a set of readonly attributes of a grid. For example:

Grid: ColumnA
ColumnB
Column C

OptionGroup:
Option1
Option2

If Option1 => ColumnB.readonly(true) / ColumnC.readonly(false)
if Option2 => ColumnB.readonly(false) / ColumnC.readonly(true)

How can I accomplish this scenario? What would be the API to access property ReadOnly of a given column?
Thanks in advance

German

2 Answers, 1 is accepted

Sort by
0
German
Top achievements
Rank 1
answered on 11 May 2012, 01:32 PM
Anyone??
0
German
Top achievements
Rank 1
answered on 22 May 2012, 03:20 PM
Ok, after several days trying to work this out, I finally made it work. Here's the code I used:

$("#optionEditA").click(function () {
    var grid = $("#sampleGrid").data("t-grid");
    var columnA = grid.columnFromTitle("ColumnA");
    var columnB = grid.columnFromTitle("ColumnB");
 
    columnA.readonly = false;
    columnB.readonly = true;
});
 
$("#optionEditB").click(function () {
    var grid = $("#sampleGrid").data("t-grid");
    var columnA = grid.columnFromTitle("ColumnA");
    var columnB = grid.columnFromTitle("ColumnB");
 
    columnA.readonly = true;
    columnB.readonly = false;
});

I'm sure there are other ways (more efficient) to make this work but for now this helped me.

Hope it helps someone else
Tags
Grid
Asked by
German
Top achievements
Rank 1
Answers by
German
Top achievements
Rank 1
Share this question
or