Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Richard Hunter on Jul 31, 2009 07:47
open dhtmlx forum
TreeGrid open folder on double click

Hi, I'm wondering if it is possible to have a folder in a TreeGrid open when the text is double clicked and not just when the + symbol is clicked.

Your help is appreciated!
Answer posted by Alex (support) on Jul 31, 2009 09:33

Hello, 

you can use onEditCell event handler. For example:

grid.attachEvent("onEditCell",function(stage,id,index){
 if(index ==0){ /*for tree in the1st column*/
  grid.openItem(id)
  return false
 } 
 return true
})



Answer posted on Aug 02, 2009 07:30
Hi,

Thanks for the help with this.

The code you provided did open folders on double click, however on double clicking, the cell text was wiped. I tried changing code to the following:

treegrid.attachEvent("onEditCell",function(stage,id,index){
 if(index ==0){
  treegrid.openItem(id)
  return true
 }
 return true
})

This left the cell text intact. The only problem I have now is that when you reach the bottom level folder, if the text is double clicked, it is editable. If I use the command   treegrid.setEditable("no");   the above code will not work. I need the last stage of the folders to be read-only. Can you suggest a way that this can be achieved?

Thanks
Answer posted by dhxSupport on Aug 03, 2009 06:20
You can use "onRowDblClicked" event to define when necessary cell was double clicked. 
 grid.attachEvent("onRowDblClicked", function(rId,cInd){
      if (cInd==0){
      grid.openItem(id)
      return false
      }
     return true
});
Answer posted by Richard Hunter on Aug 03, 2009 07:50
Hi, that worked perfectly although there was a slight error in the code you provided. The correct code for anyone else wishing to do this is:

 grid.attachEvent("onRowDblClicked", function(rId,cInd){
      if (cInd==0){
      grid.openItem(rId)
      return false
      }
     return true
});

Many thanks