EasyUI Forum
October 12, 2025, 01:59:14 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: Change backgroundColor of combotree in datagrid filter  (Read 9764 times)
hatux7
Newbie
*
Posts: 7


View Profile Email
« on: June 28, 2017, 08:06:22 AM »

Hello

I search to achieve this but nothing seems to work, i have a datagrid with a filter and one of the fields is type 'combotree', i want to every time the user check an option in the combotree the combotree change the background to green.

I can do this with: textbox, numberbox, combobox, and datebox with this code:

Code:
$('#myTextbox').textbox('textbox').css({backgroundColor: '#BAD7C9', color: '#515D57'});

but i dont know how to do the same in combotree, if i use this code throws error.

Can you help me please!
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: June 29, 2017, 02:19:47 AM »

This code has no problem.
Code:
$('#cc').combotree('textbox').css({backgroundColor: '#BAD7C9', color: '#515D57'});
Logged
hatux7
Newbie
*
Posts: 7


View Profile Email
« Reply #2 on: June 29, 2017, 10:51:44 AM »

This code has no problem.
Code:
$('#cc').combotree('textbox').css({backgroundColor: '#BAD7C9', color: '#515D57'});

You are right, if you create the combotree with an id like this:

Code:
$('#cc').combotree({
    url: 'get_data.php',
    required: true
});

that code works, the problem is my combotree has no id, because is create inside the datagrid filter:

Code:
$('#dg').datagrid('enableFilter',[
{
  field:'users',
  type:'combotree',
  options:{
    url:'get_users.php',
    multiple:true,
    checkbox:true,
    onCheck:function(node,checked){
        $('#dg').datagrid('addFilterRule', {
           field: 'users',
           op: 'equal',
           value: node.text
        }).datagrid('doFilter');

        //Change the background color here
    }
  }
}
]);


I tried to change with:
Code:
$(this).parent().combotree('textbox').css({backgroundColor: '#BAD7C9', color: '#515D57'});

But in console throws error: Uncaught TypeError: Cannot read property 'textbox' of undefined


So the only way i can do this is with:
Code:
$('#dg').datagrid('getFilterComponent','users').combotree('textbox').css({backgroundColor: '#BAD7C9', color: '#515D57'});

But i don't know if is the best way.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: June 29, 2017, 03:39:30 PM »

The simplest way to get a filter component is to call the 'getFilterComponent' method, just you pointed out.
Code:
$('#dg').datagrid('getFilterComponent','users').combotree('textbox').css({backgroundColor: '#BAD7C9', color: '#515D57'});

You can also try this code.
Code:
onCheck: function(){
    var p = $(this).closest('.combo-panel');
    var combo = p.panel('options').comboTarget;
    $(combo).combotree('textbox').css({backgroundColor: '#BAD7C9', color: '#515D57'});
}

Or this code.
Code:
onInit: function(){
    var t = $(this).combotree('tree');
    t.tree('options').combo = this; // store the combo object
},
onCheck: function(){
    var combo = $(this).tree('options').combo;
    $(combo).combotree('textbox').css({backgroundColor: '#BAD7C9', color: '#515D57'});
}
Logged
hatux7
Newbie
*
Posts: 7


View Profile Email
« Reply #4 on: July 03, 2017, 10:07:10 AM »

stworthy thank you for all your help, now my page works very nice  Smiley
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!