How to update TreeGrid Node Icon dynamically

Hi,
We are using a TreeGrid and set customIconProperty for that to have different icons for each Node. Thats working fine.

In a particular case we weed to update a Node values ( along with Node Icon )dynamically.
We have used setEditValues() and refreshRow() combination. By doing so we can able to change all the display values but other than Node Icon.

We saw other post with the same problem and what you have suggested is using
refershCell. We have tried the same but that is not solving our need.

Here is the sample program that depics our need.
We have modified Tree -> Initial Data example in SmartClient Explorer

isc.TreeGrid.create({
    ID: "employeeTree",
    width: 500,
    height: 200,
    dataSource: "employees",
    customIconProperty:"myIcon",     
    showOpenIcons:false,
    showDropIcons:false,
    closedIconSuffix:"",
    fields: [
        {name: "Name"},
        {name: "Job"}
    ],
    dataProperties: {openProperty: "isOpen"},
    initialData: [
        {EmployeeId:"4", myIcon:"icons/16/person.png", ReportsTo:"1", Name:"Charles Madigen", Job:"Chief Operating Officer", 
         isOpen: true},
        {EmployeeId:"192", myIcon:"icons/16/person.png", ReportsTo:"4", Name:"Ralph Brogan", Job:"Mgr Software Client Supp"},
        {EmployeeId:"191", myIcon:"icons/16/person.png", ReportsTo:"4", Name:"Tammy Plant", Job:"Mgr Cap Rptg Dist"},
        {EmployeeId:"190", myIcon:"icons/16/person.png", myIcon:"icons/16/person.png", ReportsTo:"4", Name:"Carol Finley", Job:"Mgr Fin Rpts Budgets"},
        {EmployeeId:"189", myIcon:"flags/16/US.png", ReportsTo:"4", Name:"Gene Porter", Job:"Mgr Tech Plng IntIS T"},
        {EmployeeId:"188", myIcon:"flags/16/US.png", ReportsTo:"4", Name:"Rogine Leger", Job:"Mgr Syst P P"}, 
        {EmployeeId:"187", myIcon:"flags/16/US.png", ReportsTo:"4", Name:"Abigail Lippman", Job:"Mgr Proj Del"}, 
        {EmployeeId:"186", myIcon:"flags/16/US.png", ReportsTo:"4", Name:"John Garrison", Job:"Mgr Site Services"}
        
    ]
});
isc.IButton.create({
    top:210,
    title:"Change Values",
    click:function(){
       var rowNum = employeeTree.getRecordIndex(employeeTree.data.find('EmployeeId',191));
       employeeTree.setEditValues(rowNum,{EmployeeId:"191", myIcon:"flags/16/US.png", ReportsTo:"4", Name:"Changed for Testing", Job:"Changed for Testing"});    
       employeeTree.refreshRow(rowNum);
       var colNum = employeeTree.getFieldNum('Name');
       employeeTree.refreshCell(rowNum,colNum); 
    
}
});

in this example ,we need to upate the Node Icon for the Node with primary key 191 as ‘flags/16/US.png’.
How to do this? Help us.

Hi Mahen,

setEditValue() is for creating unsaved edits that you will later want to save, and is designed to match what would happen if the user made the changes via inline editing. If you are instead making purely presentation changes or other client-side changes that don’t need saving, you can safely directly modify the record.

Hi,
Thanks for the reply.

you can safely directly modify the record.

Can you help me to understand how to modify it safely?

All i need here is the code to chagne the icon.
Can you give me a hint or code to complete this click method ( from the sample program i gave earlier)

isc.IButton.create({
    top:210,
    title:"Change Values",
    click:function(){
       var rowNum = employeeTree.getRecordIndex(employeeTree.data.find('EmployeeId',191));
       employeeTree.setEditValues(rowNum,{EmployeeId:"191", myIcon:"flags/16/US.png", ReportsTo:"4", Name:"Changed for Testing", Job:"Changed for Testing"});    
       employeeTree.refreshRow(rowNum);
       var colNum = employeeTree.getFieldNum('Name');
       employeeTree.refreshCell(rowNum,colNum); 
    
}

Thanks

Records are JavaScript Objects.

       var record = employeeTree.data.find('EmployeeId',191);
       var rowNum = employeeTree.getRecordIndex(record);
       record.myIcon = "flags/16/US.png"; 
       employeeTree.refreshRow(rowNum);

Obviously I can’t actually run this code, so watch for typos.