EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: catpaw on January 23, 2014, 11:40:09 AM



Title: set disable editing for some row [treegrid]
Post by: catpaw on January 23, 2014, 11:40:09 AM
hello everyone!

I need set (for some row's) a property like disabled to disallow that row be modified

I have a treegrid that displays 3 levels

the goal: the rows that are editable only leaf, no parents

I thought about putting a flag in the data I receive json but
Is there a property to disable a row in the editing?

EDit----------

Like I said

I put a flag in my json data for every row, some like: edit: true or edit: false

Then I did this function:

Code:
onBeforeEdit: function(row){
            if(row.edit==false){
                      id = row.id;
                      $('#treegrid').treegrid('cancelEdit',id);
                      editingId = undefined;
                }
            }

I get the flag...that's ok

the problem is that the cancelEdit method is not working

if I put a alert message like alert(row.id) I see the id of the row ok

but the row stays the editor's field's in edit mode


Title: Re: set disable editing for some row [treegrid]
Post by: catpaw on January 23, 2014, 01:27:31 PM
hi again

I think I solved the problem.

remove the function onBeforeEdit event and add the function edit () the condition of the flag:

Code:
function edit(){
if (editingId != undefined){
$('#treegrid').treegrid('select', editingId);
return;
}
var row = $('#treegrid').treegrid('getSelected');
if (row){
if(row.edit==false){
id = row.id;
$('#treegrid').treegrid('cancelEdit',id);
editingId = undefined;
} else{
editingId = row.id;
$('#treegrid').treegrid('beginEdit', editingId);
editingIdActual = editingId;
}
}
}

What do you think?


Title: Re: set disable editing for some row [treegrid]
Post by: stworthy on January 23, 2014, 07:34:41 PM
Returning false in 'onBeforeEdit' will cancel the editing action. Please try this.
Code:
$('#tg').treegrid({
onBeforeEdit:function(row){
if (row.edit == false){
return false;
}
}
});