EasyUI Forum
April 30, 2024, 01:35:27 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: How I can control whether a cell is editable or not?  (Read 5553 times)
catpaw
Jr. Member
**
Posts: 85


View Profile Email
« on: February 11, 2014, 06:01:59 PM »

hello fellow!!

I have an editable treegrid where I need to allow or block the edition of each cell depending on its value.

if the cell value is equal to null -> not allow that cell is editable
if the cell value is different from null -> allow editing of that cell

the problem is that I can not block editing an entire row or column because there will be cells in the same column that may or may not be editable, same for the row. For example:

here the treegrid:

+--------------------+------------------------------------+-----------------------------------+----------------------------------+
|       TITLE            |           Column 1                       |           Column 2                     |           Column 3                     |
|                           |  subcolum 1.1  |  subcolum 1.2  |  subcolum 2.1 | subcolum 2.2  | subcolum 3.1 | subcolum 3.2   |
+--------------------+------------------------------------+-------------------------------+--------------------------------------+
|     topic  1            |   cell editable   |  cell editable   |   cell editable   |  cell editable   | cell editable   |  cell editable    |
+--------------------+------------------------------------+-----------------------------------+----------------------------------+
|     topic  2            |   cell editable   |  cell editable   |   No editable    |  No  editable   |  No editable   |  No editable     |
+--------------------+------------------------------------+-----------------------------------+----------------------------------+
|     topic  3            |   cell editable   |  cell editable   |   cell editable   |  cell editable    |  No editable   |  No editable    |
+--------------------+------------------------------------+-----------------------------------+----------------------------------+
|     topic  4            |   No editable    |  No  editable   |  No editable     |   No editable   |  No editable   |  No editable    |
+--------------------+------------------------------------+-----------------------------------+----------------------------------+

any idea?
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: February 12, 2014, 12:32:35 AM »

Please use 'onBeforeEdit' event to set the field editors according to the row values. The code below shows how to achieve this functionality.

Code:
$('#tg').treegrid({
onBeforeEdit:function(row){
var col = $(this).treegrid('getColumnOption', 'end');
if (row.name == 'Coding'){
col.editor = null;
} else {
col.editor = 'datebox';
}
}
})
Logged
catpaw
Jr. Member
**
Posts: 85


View Profile Email
« Reply #2 on: February 12, 2014, 01:40:59 PM »

hi thank you

cost me some time to understand, but it succeeds

so far so good!!

thank you very much
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!