Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by choesang on Jan 18, 2010 08:21
open dhtmlx forum
setItemColor does not work with array item

Hi!
I am using dhtmlxtree Version 2.0
It works when i use in a straight forward manner: tree.setItemColor(tree.getSelectedItem(),'#F2F2F2','#F2F2F2');

I have this function:
function filterLock(lod){
            var    allNodes = tree.getAllSubItems(0); // consider that you always get the root node ID by magic
            var allNodesList = allNodes.split(','); // books,lb,lb_1,lb_2,lb_3,lb_4,lb_5,rc,rc_1,rc_2,rc_3,rc_4,rc_5
                for(var i = 0; i < allNodesList.length; i++){
                    var lodBoolean = tree.getUserData(allNodesList[i], lod);                    
                    if (lodBoolean == "false" ){
                        tree.lockItem(allNodesList[i], true); //this works
                        tree.setItemColor(allNodesList[i],'#F2F2F2','#F2F2F2');    //this doesn't work                    
                    }
                    else {
                        tree.lockItem(allNodesList[i], false);    
                    }
                }            
        }    

If you check this function, lockItem() works and setItemColor() does not work. If the data is not in the right format than lockItem() should not also work.

Can you please give me a hint, where i am going wrong?

--Choesang
Answer posted by Alex (support) on Jan 18, 2010 09:05

Hello

lockItem method blocks all method for a certain item. 

So please call setItemColor method before lockItem:

...

tree.setItemColor(allNodesList[i],'#F2F2F2','#F2F2F2');

tree.lockItem(allNodesList[i], true); 

...