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

Set grid editable/uneditable

2 Answers 445 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 18 Jun 2012, 05:45 PM
I apologize if this has been asked before, the forum search didn't seem to turn up the answer.

I am creating a grid with editable=false. Later on, if conditions are satisfied, I want to set editable=true. I haven't been able to find anything in the API, is this even possible in 2012.1.311? Or am I going to have to destroy and recreate the grid?

2 Answers, 1 is accepted

Sort by
0
Accepted
Alexander Valchev
Telerik team
answered on 19 Jun 2012, 11:09 AM
Hi Steve,

I am afraid that this is not supported at present - the editing cannot be enabled/disabled after the grid's initialization. Depending on the editing mode that you are using, you can try to catch the click event of the corresponding buttons and prevent the entering in edit mode. For example:
dataBound: function() {
    $("#grid .k-button.k-grid-edit").click(function(e){
        e.stopPropagation(); //disable entering in edit mode
    })
}


All the best,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Steve
Top achievements
Rank 1
answered on 19 Jun 2012, 01:50 PM
Alexander,

Thanks for the reply. I'm using batch editing so there isn't that particular button to stop, but your suggestion does give me another idea for a workaround. When I am showing the editable grid, I'm preventing certain rows from being edited by immediately closing the edit cell UI based on a field in the row data:

edit: function (e) {
if (e.model.IsReadOnly) {
$('#myGrid').data("kendoGrid").closeCell();
}
} 

I can modify that event so that if we're in a non-editable mode, it always prevents the event from occurring.
Tags
Grid
Asked by
Steve
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Steve
Top achievements
Rank 1
Share this question
or