EasyUI Forum
April 20, 2024, 04:44:58 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: update row after edit, but the styler property does not change  (Read 5310 times)
catpaw
Jr. Member
**
Posts: 85


View Profile Email
« on: July 12, 2017, 08:50:15 AM »

hi I have a datagrid with one cell editing:

Code:
<th data-options="field:'tag',width:80,align:'center',halign:'center',sortable:true,
                        styler: function (value,row,index){
                                return 'background-color:'+row.codigo+';';
                            },
                            formatter:function(value,row){
                            return row.tag;
                            },
                            editor:{
                                type:'combobox',
                                options:{
                                    valueField:'id_estatus',
                                    textField:'tag',
                                    method:'get',
                                    url:'retrieve/get_cmb.php',
                                    required:true,
                                    editable: false,
                                    onLoadSuccess:function(data){
                                        //alert(JSON.stringify(data));
                                    },
                                    onLoadError:function(data){
                                        //alert(JSON.stringify(data));
                                    }
                                }
                            }">TAG</th>

As you can see, the styler property gets the background color from a row.codigo, so after edit this row I want the background color changes as well.

I see the updateRow method, but I cant figure out how use it to change the styler property

$('#dg').datagrid('updateRow',{
   index: 2,
   row: { --------------------------------\
      name: 'new name',-------------> No need this
      note: 'new note message'-----/
   }--------------------------------------/
   styler: row.codigo, -----------------------------> how set the new background color?Huh??
});

Thank you
Logged
catpaw
Jr. Member
**
Posts: 85


View Profile Email
« Reply #1 on: July 17, 2017, 08:14:02 AM »

Well, I assume it's not possible

 Undecided
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #2 on: July 17, 2017, 05:09:37 PM »

Your styler function relies on the row field value(row.codigo). To change the background color, just change this field value as you want.
Code:
styler: function (value,row,index){
   return 'background-color:'+row.codigo+';';
}

You can call the 'updateRow' method to change the field values.
Code:
$('#dg').datagrid('updateRow',{
   index: 2,
   row: { --------------------------------\
      name: 'new name',-------------> No need this
      note: 'new note message',-----/
      codigo: '#ccc'  // new value here
   }--------------------------------------/
});

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!