Search code examples
extjsextjs4extjs4.1treegrid

ExtJS 4.1.1: Working with a TreeGrid/TreeStore


I am having some problems with my code that I hoped you could help me with as I've kind of hit a wall.

I have a field in a Tree grid that has the following properties:

    xtype : 'gridcolumn',
    id : 'raGridFormulaLink_Purchased',
    dataIndex: 'formulaLink',
    groupable : false,
    editor : {
        xtype: 'textfield'
    },      
    renderer: function(value, metaData, record, rowIndex, colIndex, store) {
        var rVal; var linkRec;
        if(value !== '' && value !== 0) {
            /* TODO Find linked Record based on ['child_id' => value] 
             * and print that record's [text] to rVal */
            rVal = Ext.local.langstore[448] + ' ' + value;
        }
        return rVal;
    },
    align: 'left',
    width: 100

As you can see I am trying to do a simple HLOOKUP to find the linked record. But I am unable to get the proper record from the store. How can I do this?

The value has the right "child_id", so it's not the input that's wrong.

Any help appreciated,

GR.


Solution

  • Solved it.

    Final code:

        renderer: function(value, metaData, record, rowIndex, colIndex, store) {
            var rVal; var rText = ''; var node;
    
            if(value !== '' && value !== 0) {
                if(record.isLeaf()) {
                    var node = record.parentNode.findChild('child_id',value);
                    rText = node.data.text;
                    rVal = Ext.local.langstore[448] + ' ' + rText;
                }
            }
            return rVal;
        },