Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Sebas on Jul 13, 2009 18:09
open dhtmlx forum
custom Excell tree

Hi,

I use the Entreprise version of dhtmxTreeGrid and I try to create a custom Excell tree so it become read only (no editable label field).

First, is there a simpler solution ? I need all the cells of my first column to become non editable, read only tree cells.

I followed instructions from the doc, but the result is not a tree cell, but its more a common 'ro' cell. Here is my first attempt code :

    function eXcell_rotree(cell)
    {
        //excell name is defined here
        if(cell)
        {
            //default pattern, just copy it
            this.cell = cell;
            this.grid = this.cell.parentNode.grid;
            eXcell_tree.call(this); //use methods of "tree" excell
        }
    
        this.edit = function(){ }
        
        this.detach = function(){ }
    };
    
    eXcell_rotree.prototype = new eXcell; // nest all other methods from base class


Reading the source code, I found that the functionnality also reside in the two prototype definitions for setValueA and setValue that are set on the eXcell_tree after its created from the base class. So I tried two different techniques :

My first guess was to subclass from the eXcell_tree class instead of eXcell :

    function eXcell_rotree(cell)
    {
        ...
    };
    
    eXcell_rotree.prototype = new eXcell_tree; // nest all other methods from tree class

My second try was to entirely replicate the full eXcell tree definition without changing a byte, except for adding 'ro' before tree.
At this point I did not even tried to change the edit() method of the class :

    function eXcell_rotree(cell)
    {…};
    
    eXcell_rotree.prototype = new eXcell;
            
    eXcell_rotree.prototype.setValueA = function(content)
    {…};

    eXcell_rotree.prototype.setValue = function(valAr)
    {…};

In both tries, I always run in errors or undefined grid properties ('this.grid._tgc' [undefined] is not an object.). My understanding is that all dhtmxTreeGrid additionnal properties are undefined at this point ( _tgc, _h2 ). In my second version, I tried to pre-create thoses properties upfront with some success for _tgc and _h2, but then I run in 'row' undefined, and I'm stuck there.

Finally, I gave up and went for the bad and ugly fix - I edited my codebase optimised version of dhtmlxtreegrid.js like this :

this.edit = function(){
// added by ...
return;

This is working indeed, but now my solution has no more access to editable tree eXcell.

I would highly prefer a more legit solution with a clean untouched library.

Thank you,

--
Sebastien
Answer posted by dhxSupport on Jul 14, 2009 01:14
To make "tree" cell not editable you can add following line to the treeGrid init:
treeGrid.enableTreeCellEdit(false)