EasyUI Forum
May 17, 2024, 06:13:47 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: set disable editing for some row [treegrid]  (Read 6305 times)
catpaw
Jr. Member
**
Posts: 85


View Profile Email
« 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
« Last Edit: January 23, 2014, 12:30:13 PM by catpaw » Logged
catpaw
Jr. Member
**
Posts: 85


View Profile Email
« Reply #1 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?
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #2 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;
}
}
});
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!