Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Arno Vanbeginne/Xenon54 on Mar 12, 2009 02:24
open dhtmlx forum
Opening a subtree by means of a function

Hi,

I'm having trouble opening a subtree in a treegrid by means of a function.

The definition of my grid is the following: mygrid.setColTypes("tree,stree,...
I want the subtree to open by a function which I can put in a button.

Is it also possible to get the selected value or id from the subtree, run it through a function and replace the value in the grid by the value resulting from the function? In other words is it possible to put a value in the subtree cell that is not a value in the subtree?

kind regards,
Arno.
Answer posted by dhxSupport on Mar 12, 2009 03:47

>>The definition of my grid is the following: mygrid.setColTypes("tree,stree,... I want the subtree to open by a function which I can put in a button.

<button onclick="(arguments[0]||window.event).cancelBubble=true;openSubTree()">Open</button>

..

function openSubTree(){
  mygrid.selectCell(rowId,cellInd);
  mygrid.editCell(); 
 }
>>Is it also possible to get the selected value or id from the subtree, run it through a function and replace the value in the grid by the value resulting from the function? In other words is it possible to put a value in the subtree cell that is not a value in the subtree?

When subTree opens "onEditCell" event fires. So you can use it to manipulate with subTree:

mygrid.attachEvent("onEditCell",doOnEditCell);

...

function doOnEditCell(stage,rowId,cellInd,newValue,oldValue){
  if ((stage==1)&&(cellInd==2)){
  var selectedId=tree.getSelectedItemId();
  var selectedText=tree.getSelectedItemText();
  tree.setItemText(selectedId,"newValue","newTooltip");
  }
  return true;
 }