Page 44 of 44 FirstFirst ... 34424344
Results 431 to 432 of 432

Thread: TreeGrid (Ext.ux.maximgb.treegrid) extension.

  1. #431

    Default

    Thanks for wonderful component. I am using extjs 3.4 and treegrid extension.

    I am getting console error
    Code:
    TypeError: this.ds.getSortState is not a function
    So I changed store at grid to

    Code:
    store: Ext.create('store')
    now I am getting error

    TypeError: b[(intermediate value)] is not a constructor
    Please kindly help me to sort out this

    Thanks in advance
    Last edited by priyapratheep; 30 Sep 2015 at 7:55 PM. Reason: formating

  2. #432
    Sencha User
    Join Date
    Nov 2015
    Posts
    1

    Default

    Hi demongloom
    I used the changes you made to the maximgb.treegrid, but nothing happened to me. I found errors in firebug :
    Code:
    TypeError: row.getAttribute is not a function
    For this line :
    Code:
                r[ row.getAttribute("rowIndex") ] = row;
    I'm using Ext version 2.1
    Can you tell me why i'm getting this exception ?
    I'm new to extjs, so can you help me please understand why im getting this error ?
    Thanks


    Quote Originally Posted by demongloom View Post
    Hi Maxim,

    Your plugin is very useful for me and mine cms. But sometimes I have a performance issues. I did a few important updates for treestore and treeview to improve this situation. In the most cases I got 15x times bigger performance.

    In my cms I need to be able load 1k-2k records into tree grid. I know it is not correct architecture, can be solved by ajax loading on child nodes. But in case of ajax I got delays and browser freezes on not too much big amounts of records.

    WARNING:
    It is a extreme version of TreeGrid. It can be work nice, fast and stable, but contains hacks and tricks. Be careful in use.

    Changes:

    1. Allow to pass options for store loadData function. Currently affects only applySort option, which can disable initial applySort function call.

    When use: data comes from server/direct in html already sorted by tree, so disabling of apply sort can avoid non required sort. Increase data loading performance.

    Example:

    store.loadData( dataVariable, false, { applySort: false } );

    2. Caching of parent-child relations.
    I've rewrited getRootNodes() and getNodeChildren() functions for AdjacencyListStore.
    These functions now use caching for their results. Store do cache clear on datachanges.
    Cache results calculated once, on first time call. Also functions use direct data access (record.data.field) instead of record.get(field). Direct access to data gave 15x performance boost. Thanks to firebug profiling.

    3. TreeGridView render on expand change.
    I've hacked rendering for grid view. Now its render only expanded nodes, and pre render childs only on request (node expanding). It makes possible to load a big amount into store, but render only visible ones. Main problem I got during implementation and testing is incorrect rowIndex. ExtJS calculate RI depending on element's dom position, but I did a change to store RI as dom element attribute. Next problem what I solved it whats to do with unrendered/unaccessible dom element.

    4. Fix of case when node have childrens (they are already loaded in store), but because of filter applied (like grid search), when expanding this node, store act this node as without childrens and try to load them using ajax. If url missing, it cause js error.


    PHP Code:
    Ext.namespace('Ext.ux.maximgb.treegrid');

    /**
     * This class shouldn't be created directly use NestedSetStore or AdjacencyListStore instead.
     *
     * @abstract
     */
    Ext.ux.maximgb.treegrid.AbstractTreeStore Ext.extend(Ext.data.Store, {
        
    /**
         * @cfg {String} is_leaf_field_name Record leaf flag field name.
         */
        
    leaf_field_name'_is_leaf',
        
        
    /**
         * Current page offset.
         *
         * @access private
         */
        
    page_offset0,
        
        
    /**
         * Current active node.
         *
         * @access private
         */
        
    active_nodenull,
        
        
    /**
         * @constructor
         */
        
    constructor: function(config) {
            
            
    Ext.ux.maximgb.treegrid.AbstractTreeStore.superclass.constructor.call(thisconfig);
            
            if (!
    this.paramNames.active_node) {
                
    this.paramNames.active_node 'anode';
            }
            
            
    this.addEvents(        
            
    /**
             * @event beforeexpandnode
             * Fires before node expand. Return false to cancel operation.
             * param {AbstractTreeStore} this
             * param {Record} record
             */
            
    'beforeexpandnode',  
            
    /**
             * @event expandnode
             * Fires after node expand.
             * param {AbstractTreeStore} this
             * param {Record} record
             */
            
    'expandnode'
            
    /**
             * @event expandnodefailed
             * Fires when expand node operation is failed.
             * param {AbstractTreeStore} this
             * param {id} Record id
             * param {Record} Record, may be undefined
             */
            
    'expandnodefailed',  
            
    /**
             * @event beforecollapsenode
             * Fires before node collapse. Return false to cancel operation.
             * param {AbstractTreeStore} this
             * param {Record} record
             */
            
    'beforecollapsenode',  
            
    /**
             * @event collapsenode
             * Fires after node collapse.
             * param {AbstractTreeStore} this
             * param {Record} record
             */
            
    'collapsenode',  
            
    /**
             * @event beforeactivenodechange
             * Fires before active node change. Return false to cancel operation.
             * param {AbstractTreeStore} this
             * param {Record} old active node record
             * param {Record} new active node record
             */
            
    'beforeactivenodechange',  
            
    /**
             * @event activenodechange
             * Fires after active node change.
             * param {AbstractTreeStore} this
             * param {Record} old active node record
             * param {Record} new active node record
             */
            
    'activenodechange');
        },
        
        
    // Store methods.
        // -----------------------------------------------------------------------------------------------    
        /**
         * Removes record and all its descendants.
         *
         * @access public
         * @param {Record} record Record to remove.
         */
        
    remove: function(record){

            if (
    record === this.active_node) {
                 
    this.setActiveNode(null); }
                
            
    this.removeNodeDescendants(record);
            
            
    Ext.ux.maximgb.treegrid.AbstractTreeStore.superclass.remove.call(thisrecord);
        },
        
        
    /**
         * Removes node descendants.
         *
         * @access private
         */
        
    removeNodeDescendants: function(rc){
            
            var 
    ilenchildren this.getNodeChildren(rc);
            
            for (
    0len children.lengthleni++) {
                
    this.remove(children[i]); }
                
        },
        
        
    /**
         * Applyes current sort method.
         *
         * @access private
         */
        
    applySort: function(){

            if (
    this.sortInfo && !this.remoteSort) {
                
                var 
    this.sortInfos.field;
                
    this.sortData(fs.direction);
                
            } else {
                
                
    this.applyTreeSort();
                
            }    
    // if

        
    },
        
        
    /**
         * Sorts data according to sort params and then applyes tree sorting.
         *
         * @access private
         */
        
    sortData: function(fdirection){
            
            
    direction direction || 'ASC';
            
            var 
    st this.fields.get(f).sortType;
            
            var 
    fn = function(r1r2) {
                var 
    v1 st(r1.data[f]), v2 st(r2.data[f]);
                return 
    v1 v2 : (v1 v2 ? -0);
            };
            
            
    this.data.sort(directionfn);

            if (
    this.snapshot && this.snapshot != this.data) {
                
    this.snapshot.sort(directionfn); }

            
    this.applyTreeSort();

        },
        
        
    /**
         * Loads current active record data.
         */
        
    load: function(options){
        
            if (
    options) {
                
                if (
    options.params) {
                    
                    if (
    options.params[this.paramNames.active_node] === undefined) {
                        
    options.params[this.paramNames.active_node] = this.active_node this.active_node.id null; }
                        
                } else {
                    
                    
    options.params = {};
                    
    options.params[this.paramNames.active_node] = this.active_node this.active_node.id null;
                    
                }    
    // if
                
            
    } else {
                
                
    options = {
                    
    params: {}
                };
                
                
    options.params[this.paramNames.active_node] = this.active_node this.active_node.id null;
                
            }    
    // if
            
            
    if (options.params[this.paramNames.active_node] !== null) {
                
    options.add true; }
            
            return 
    Ext.ux.maximgb.treegrid.AbstractTreeStore.superclass.load.call(thisoptions);
            
        },
        
        
    /**
         * Allow to pass options
         */
        
    loadData : function(oappendopt){
            
            var 
    this.reader.readRecords(o);
            var 
    opt opt || {};
            
    opt.add append;
            
            
    this.loadRecords(ropttrue);
            
        },
        
        
    /**
         * Called as a callback by the Reader during load operation.
         *
         * @access private
         */
        
    loadRecords: function(ooptionssuccess){
            
            if (!
    || success === false) {
                
                if (
    success !== false) {
                    
    this.fireEvent("load"this, [], options); }
                    
                if (
    options.callback) {
                    
    options.callback.call(options.scope || this, [], optionsfalse); }
                    
                return;
                
            }
            
            var 
    o.records
                
    o.totalRecords || r.length
                
    page_offset this.getPageOffsetFromOptions(options), 
                
    loaded_node_id this.getLoadedNodeIdFromOptions(options), 
                
    loaded_node
                
    i
                
    len
                
    self this
            
    ;
            
            if (!
    options || options.add !== true || loaded_node_id === null) {
                
                if (
    this.pruneModifiedRecords) {
                    
    this.modified = []; }
                
                for (var 
    0len r.lengthleni++) {
                    
    r[i].join(this); }
                
                if (
    this.snapshot) {
                    
                    
    this.data this.snapshot;
                    
    delete this.snapshot;
                    
                }

                
    this.data.clear();
                
    this.data.addAll(r);
                
    this.page_offset page_offset;
                
    this.totalLength t;
                
                if( 
    options.applySort == undefined ) {
                    
    options.applySort true; }
                
                if( 
    options.applySort ) {
                    
    this.applySort(); }

                
    this.fireEvent("datachanged"this);

                
            } else {

                
    loaded_node this.getById(loaded_node_id);
                
                if (
    loaded_node) {
                
                    
    this.setNodeChildrenOffset(loaded_nodepage_offset);
                    
    this.setNodeChildrenTotalCount(loaded_nodeMath.max(tr.length));
                    
                    
    this.removeNodeDescendants(loaded_node);
                    
    this.suspendEvents();
                    
                    for (
    0len r.lengthleni++) {
                        
    this.add(r[i]);
                    }
                    
                    if( 
    options.applySort == undefined ) {
                        
    options.applySort true; }
                    
                    if( 
    options.applySort ) {
                        
    this.applySort(); }
                    
                    
    this.resumeEvents();
                    
                    
    idx = [];
                    
                    
    r.sort( function(r1r2) {
                        
                        return (
    self.data.indexOf(r1) > self.data.indexOf(r2) ) ? : -1
                        
                    });
                    
                    
    this.suspendEvents();
                    
                    for (
    0len r.lengthleni++) {
                        
    this.fireEvent("add"this, [r[i]], this.data.indexOf(r[i])); }
                    
                    
    this.resumeEvents();
                    
    this.fireEvent("datachanged"this);
                    
                }
                
            }
            
            
    this.fireEvent("load"thisroptions);
            
            if (
    options.callback) {
                
    options.callback.call(options.scope || thisroptionstrue); }
            
        },
        
        
    // Tree support methods.
        // -----------------------------------------------------------------------------------------------
        
        /**
         * Sorts store data with respect to nodes parent-child relation. Every child node will be
         * positioned after its parent.
         *
         * @access public
         */
        
    applyTreeSort: function() {
            
            var 
    ilentemprecrecords = [], roots this.getRootNodes();
            
            
    // Sorting data
            
    for (0len roots.lengthleni++) {
                
    rec roots[i];
                
    records.push(rec);
                
    this.collectNodeChildrenTreeSorted(recordsrec);
            }
            
            if (
    records.length 0) {
                
    this.data.clear();
                
    this.data.addAll(records);
            }
            
            
    // Sorting the snapshot if one present.
            
    if (this.snapshot && this.snapshot !== this.data) {
                
    temp this.data;
                
    this.data this.snapshot;
                
    this.snapshot null;
                
    this.applyTreeSort();
                
    this.snapshot this.data;
                
    this.data temp;
            }
            
        },
        
        
    /**
         * Recusively collects rec descendants and adds them to records[] array.
         *
         * @access private
         * @param {Record[]} records
         * @param {Record} rec
         */
        
    collectNodeChildrenTreeSorted: function(recordsrec){
            
            var 
    ilenchildchildren this.getNodeChildren(rec);
        
            for (
    0len children.lengthleni++) {
                
    child children[i];
                
    records.push(child);
                
    this.collectNodeChildrenTreeSorted(recordschild);
            }
            
        },
        
        
    /**
         * Returns current active node.
         *
         * @access public
         * @return {Record}
         */
        
    getActiveNode: function(){
            
            return 
    this.active_node;
            
        },
        
        
    /**
         * Sets active node.
         *
         * @access public
         * @param {Record} rc Record to set active.
         */
        
    setActiveNode: function(rc){
            
            if (
    this.active_node !== rc) {
                
                if (
    rc) {
                    
                    if (
    this.data.indexOf(rc) != -1) {
                        
                        if (
    this.fireEvent('beforeactivenodechange'thisthis.active_noderc) !== false) {
                            
                            
    this.active_node rc;
                            
    this.fireEvent('activenodechange'thisthis.active_noderc);
                            
                        }    
    // if
                        
                    
    } else { 
                        
                        throw 
    "Given record is not from the store."
                        
                    }    
    // if
                    
                
    } else {
                    
                    if (
    this.fireEvent('beforeactivenodechange'thisthis.active_noderc) !== false) {
                        
                        
    this.active_node rc;
                        
    this.fireEvent('activenodechange'thisthis.active_noderc);
                        
                    }    
    // if
                    
                
    }    // if
            
            
    }    // if
            
            
        
    },
        
        
    /**
         * Returns true if node is expanded.
         *
         * @access public
         * @param {Record} rc
         */
        
    isExpandedNode: function(rc){
            
            return 
    rc.ux_maximgb_treegrid_expanded === true;
            
        },
        
        
    /**
         * Sets node expanded flag.
         *
         * @access private
         */
        
    setNodeExpanded: function(rcvalue){
            
            
    rc.ux_maximgb_treegrid_expanded value;
            
        },
        
        
    /**
         * Returns true if node's ancestors are all expanded - node is visible.
         *
         * @access public
         * @param {Record} rc
         */
        
    isVisibleNode: function(rc){
            
            var 
    ilenancestors this.getNodeAncestors(rc), result true;
            
            for (
    0len ancestors.lengthleni++) {
                
                
    result result && this.isExpandedNode(ancestors[i]);
                
                if (!
    result) {
                    break; }
                
            }
            
            return 
    result;
        },
        
        
    /**
         * Returns true if node is a leaf.
         *
         * @access public
         * @return {Boolean}
         */
        
    isLeafNode: function(rc){
            
            return 
    rc.data[this.leaf_field_name] == true;
            
        },
        
        
    /**
         * Returns true if node was loaded.
         *
         * @access public
         * @return {Boolean}
         */
        
    isLoadedNode: function(rc) {

            var 
    result;
            
            if (
    rc.ux_maximgb_treegrid_loaded !== undefined) {
                
                
    result rc.ux_maximgb_treegrid_loaded
                
            
    } else if (this.isLeafNode(rc) || this.hasChildNodes(rc)) {
                
                
    result true;
                
            } else {
                
                
    result false;
                
            }    
    // if
            
            
    return result;
            
        },
        
        
    /**
         * Sets node loaded state.
         *
         * @access private
         * @param {Record} rc
         * @param {Boolean} value
         */
        
    setNodeLoaded: function(rcvalue) {
            
            
    rc.ux_maximgb_treegrid_loaded value;
            
        },
        
        
    /**
         * Returns node's children offset.
         *
         * @access public
         * @param {Record} rc
         * @return {Integer}
         */
        
    getNodeChildrenOffset: function(rc) {
            
            return 
    rc.ux_maximgb_treegrid_offset || 0;
            
        },
        
        
    /**
         * Sets node's children offset.
         *
         * @access private
         * @param {Record} rc
         * @parma {Integer} value
         */
        
    setNodeChildrenOffset: function(rcvalue){
            
            
    rc.ux_maximgb_treegrid_offset value;
            
        },
        
        
    /**
         * Returns node's children total count
         *
         * @access public
         * @param {Record} rc
         * @return {Integer}
         */
        
    getNodeChildrenTotalCount: function(rc){
            
            return 
    rc.ux_maximgb_treegrid_total || 0;
            
        },
        
        
    /**
         * Sets node's children total count.
         *
         * @access private
         * @param {Record} rc
         * @param {Integer} value
         */
        
    setNodeChildrenTotalCount: function(rcvalue){
            
            
    rc.ux_maximgb_treegrid_total value;
            
        },
        
        
    /**
         * Collapses node.
         *
         * @access public
         * @param {Record} rc
         * @param {Record} rc Node to collapse.
         */
        
    collapseNode: function(rc){
            
            if(
                
    this.isExpandedNode(rc) &&
                
    this.fireEvent('beforecollapsenode'thisrc) !== false
            
    ) {
                
                
    this.setNodeExpanded(rcfalse);
                
    this.fireEvent('collapsenode'thisrc);
                
            }    
    // if
        
    },
        
        
    /**
         * Expands node.
         *
         * @access public
         * @param {Record} rc
         */
        
    expandNode: function(rc){
            
            var 
    params;
            
            if (
                !
    this.isExpandedNode(rc) &&
                
    this.fireEvent('beforeexpandnode'thisrc) !== false
            
    ) {
                
                
    // If node is already loaded then expanding now.
                
    if (this.isLoadedNode(rc)) {

                    
    this.setNodeExpanded(rctrue);
                    
    this.fireEvent('expandnode'thisrc);
                    
                } else {
                    
                    
    // If node isn't loaded yet then expanding after load.
                    
                    
    params = {};
                    
    params[this.paramNames.active_node] = rc.id;
                    
                    
    this.load({
                        
    addtrue,
                        
    paramsparams,
                        
    callbackthis.expandNodeCallback,
                        
    scopethis
                    
    });
                    
                }    
    // if
            
            
    }    // if
            
            
        
    },
        
        
    /**
         * @access private
         */
        
    expandNodeCallback: function(roptionssuccess){
            
            var 
    rc this.getById(options.params[this.paramNames.active_node]);
            
            if (
    success && rc) {
                
                
    this.setNodeLoaded(rctrue);
                
    this.setNodeExpanded(rctrue);
                
    this.fireEvent('expandnode'thisrc);
                
            } else {
                
                
    this.fireEvent('expandnodefailed'thisoptions.params[this.paramNames.active_node], rc);
                
            }    
    // if
            
        
    },
        
        
    /**
         * Returns loaded node id from the load options.
         *
         * @access public
         */
        
    getLoadedNodeIdFromOptions: function(options){
            
            var 
    result null;
            
            if (
                
    options && options.params && 
                
    options.params[this.paramNames.active_node]
            ) {
                
                
    result options.params[this.paramNames.active_node];
                
            }    
    // if
            
            
    return result;
            
        },
        
        
    /**
         * Returns start offset from the load options.
         */
        
    getPageOffsetFromOptions: function(options){
            var 
    result 0;
            if (
    options && options.params && options.params[this.paramNames.start]) {
                
    result parseInt(options.params[this.paramNames.start], 10);
                if (
    isNaN(result)) {
                    
    result 0;
                }
            }
            return 
    result;
        },
        
        
    // Public
        
    hasNextSiblingNode: function(rc){
            return 
    this.getNodeNextSibling(rc) !== null;
        },
        
        
    // Public
        
    hasPrevSiblingNode: function(rc){
            return 
    this.getNodePrevSibling(rc) !== null;
        },
        
        
    // Public
        
    hasChildNodes: function(rc){
            return 
    this.getNodeChildrenCount(rc) > 0;
        },
        
        
    // Public
        
    getNodeAncestors: function(rc){
            
            var 
    ancestors = [], parent;
            
            
    parent this.getNodeParent(rc);
            
            while (
    parent) {
                
    ancestors.push(parent);
                
    parent this.getNodeParent(parent);
            }
            
            return 
    ancestors;
            
        },
        
        
    // Public
        
    getNodeChildrenCount: function(rc){
            return 
    this.getNodeChildren(rc).length;
        },
        
        
    // Public
        
    getNodeNextSibling: function(rc) {
            
            var 
    siblingsparentindexresult null;
            
            
    parent this.getNodeParent(rc);
            
            if (
    parent) {
                
                
    siblings this.getNodeChildren(parent);
                
            } else {
                
                
    siblings this.getRootNodes();
                
            }
            
            
    index siblings.indexOf(rc);
            
            if (
    index siblings.length 1) {
                
    result siblings[index 1];
            }
            
            return 
    result;
        },
        
        
    // Public
        
    getNodePrevSibling: function(rc){
            
            var 
    siblingsparentindexresult null;
            
            
    parent this.getNodeParent(rc);
            
            if (
    parent) {
                
                
    siblings this.getNodeChildren(parent);
                
            } else {
                
                
    siblings this.getRootNodes();
                
            }
            
            
    index siblings.indexOf(rc);
            
            if (
    index 0) {
                
    result siblings[index 1];
            }
            
            return 
    result;
        },
        
        
    // Abstract tree support methods.
        // -----------------------------------------------------------------------------------------------
        
        // Public - Abstract
        
    getRootNodes: function(){
            throw 
    'Abstract method call';
        },
        
        
    // Public - Abstract
        
    getNodeDepth: function(rc){
            throw 
    'Abstract method call';
        },
        
        
    // Public - Abstract
        
    getNodeParent: function(rc){
            throw 
    'Abstract method call';
        },
        
        
    // Public - Abstract
        
    getNodeChildren: function(rc){
            throw 
    'Abstract method call';
        },
        
        
    // Public - Abstract
        
    addToNode: function(parentchild){
            throw 
    'Abstract method call';
        },
        
        
    // Public - Abstract
        
    removeFromNode: function(parentchild){
            throw 
    'Abstract method call';
        },
        
        
    // Paging support methods.
        // -----------------------------------------------------------------------------------------------
        /**
         * Returns top level node page offset.
         *
         * @access public
         * @return {Integer}
         */
        
    getPageOffset: function(){
            
            return 
    this.page_offset;
            
        },
        
        
    /**
         * Returns active node page offset.
         *
         * @access public
         * @return {Integer}
         */
        
    getActiveNodePageOffset: function(){
            
            var 
    result;
            
            if (
    this.active_node) {
                
                
    result this.getNodeChildrenOffset(this.active_node);
                
            } else {
                
                
    result this.getPageOffset();
                
            }
            
            return 
    result;
        },
        
        
    /**
         * Returns active node children count.
         *
         * @access public
         * @return {Integer}
         */
        
    getActiveNodeCount: function(){
            
            var 
    result;
            
            if (
    this.active_node) {
                
                
    result this.getNodeChildrenCount(this.active_node);
                
            } else {
                
                
    result this.getRootNodes().length;
                
            }
            
            return 
    result;
        },
        
        
    /**
         * Returns active node total children count.
         *
         * @access public
         * @return {Integer}
         */
        
    getActiveNodeTotalCount: function(){
            
            var 
    result;
            
            if (
    this.active_node) {
                
                
    result this.getNodeChildrenTotalCount(this.active_node);
                
            } else {
                
                
    result this.getTotalCount();
                
            }
            
            return 
    result;
        }
        
    });

    /**
     * Tree store for adjacency list tree representation.
     */
    Ext.ux.maximgb.treegrid.AdjacencyListStore Ext.extend(Ext.ux.maximgb.treegrid.AbstractTreeStore, {
        
    /**
         * @cfg {String} parent_id_field_name Record parent id field name.
         */
        
    parent_id_field_name'_parent',
        
        
    _cache: {},
        
        
    constructor: function(config){
            
            
    Ext.ux.maximgb.treegrid.AdjacencyListStore.superclass.constructor.call(thisconfig);
            
            
    this.clearCache();
            
            
    this.on("datachanged", function() {

                
    this.clearCache();
                
            });
            
        },
        
        
    /**
         * Cache clearance required before sort. 
        **/
        
    applyTreeSort: function() {
            
            
    this.clearCache();
            
            return 
    Ext.ux.maximgb.treegrid.AdjacencyListStore.superclass.applyTreeSort.call(this);
            
        },
        
        
    clearCache: function() {

            
    this._cache = {
                
    getRootNodesnull,
                
    getNodeChildren: {}
            };
            
        },
        
        
    load: function(options){
            
            
    this.clearCache();
            
            return 
    Ext.ux.maximgb.treegrid.AdjacencyListStore.superclass.load.call(thisoptions);
            
        },
        
        
    loadRecords: function(ooptionssuccess){
            
            var 
    ret Ext.ux.maximgb.treegrid.AdjacencyListStore.superclass.loadRecords.call(thisooptionssuccess);
            
            
    /**
             * Collect if node really loaded (have a childrens)
            **/
            
            
    var ilen,
                
    map = {}, 
                
    records this.getRange()
            ;
            
            for (
    0len records.lengthleni++) {
                
                
    map[records[i].id] = records[i]; 
                
            }    
    // for
            
            
    for (0leni++) {
                
                var 
    records[i].data[this.parent_id_field_name];
                
                if ( 
    == null) {
                    continue; }
                            
                
    map[p].ux_maximgb_treegrid_loaded true;
                        
            }    
    // for
            
            
    return ret;
            
        },
        
        
    getRootNodes: function() {
            
            if( 
    this._cache.getRootNodes ) {
                return 
    this._cache.getRootNodes; }
            
            var 
    ilenresult = [], records this.getRange();
            
            for (
    0len records.lengthleni++) {
                
                if (
    records[i].data[this.parent_id_field_name] == null) {
                    
    result.push(records[i]); }
                
            }    
    // for
            
            
    return this._cache.getRootNodes result;
        },
        
        
    getNodeDepth: function(rc){
            
            return 
    this.getNodeAncestors(rc).length;
            
        },
        
        
    getNodeParent: function(rc){
            
            if( !
    rc ) {
                return; }
            
            return 
    this.getById(rc.data[this.parent_id_field_name]);
            
        },

        
    getNodeChildren: function(rc){

            if( 
    this._cache.getNodeChildren[rc.id] != undefined ) {
                return 
    this._cache.getNodeChildren[rc.id]; }
                
            
    this._cache.getNodeChildren[rc.id] = [];

            var 
    ilenresult = [], records this.getRange();
            
            for (
    0len records.lengthleni++) {
                
                var 
    parent records[i].data[this.parent_id_field_name];
                
                if( 
    this._cache.getNodeChildren[parent] == undefined ) {
                    
    this._cache.getNodeChildren[parent] = []; }
                    
                if( 
    this._cache.getNodeChildren[records[i].id] == undefined ) {
                    
    this._cache.getNodeChildren[records[i].id] = []; }
                    
                
    this._cache.getNodeChildren[parent].push(records[i]);
                
            }    
    // for
            
            
    return this._cache.getNodeChildren[rc.id];
            
        }
        
    });

    /**
     * Tree store for nested set tree representation.
     */
    Ext.ux.maximgb.treegrid.NestedSetStore Ext.extend(Ext.ux.maximgb.treegrid.AbstractTreeStore, {
        
    /**
         * @cfg {String} left_field_name Record NS-left bound field name.
         */
        
    left_field_name'_lft',
        
        
    /**
         * @cfg {String} right_field_name Record NS-right bound field name.
         */
        
    right_field_name'_rgt',
        
        
    /**
         * @cfg {String} level_field_name Record NS-level field name.
         */
        
    level_field_name'_level',
        
        
    /**
         * @cfg {Number} root_node_level Root node level.
         */
        
    root_node_level1,
        
        
    getRootNodes: function(){
            var 
    ilenresult = [], records this.data.getRange();
            
            for (
    0len records.lengthleni++) {
                if (
    records[i].get(this.level_field_name) == this.root_node_level) {
                    
    result.push(records[i]);
                }
            }
            
            return 
    result;
        },
        
        
    getNodeDepth: function(rc){
            return 
    rc.get(this.level_field_name) - this.root_node_level;
        },
        
        
    getNodeParent: function(rc){
            var 
    result nullrecrecords this.data.getRange(), ilenlftr_lftrgtr_rgtlevelr_level;
            
            
    lft rc.get(this.left_field_name);
            
    rgt rc.get(this.right_field_name);
            
    level rc.get(this.level_field_name);
            
            for (
    0len records.lengthleni++) {
                
    rec records[i];
                
    r_lft rec.get(this.left_field_name);
                
    r_rgt rec.get(this.right_field_name);
                
    r_level rec.get(this.level_field_name);
                
                if (
    r_level == level &&
                
    r_lft lft &&
                
    r_rgt rgt) {
                    
    result rec;
                    break;
                }
            }
            
            return 
    result;
        },
        
        
    getNodeChildren: function(rc){
            var 
    lftr_lftrgtr_rgtlevelr_levelrecordsrecresult = [];
            
            
    records this.data.getRange();
            
            
    lft rc.get(this.left_field_name);
            
    rgt rc.get(this.right_field_name);
            
    level rc.get(this.level_field_name);
            
            for (
    0len records.lengthleni++) {
                
    rec records[i];
                
    r_lft rec.get(this.left_field_name);
                
    r_rgt rec.get(this.right_field_name);
                
    r_level rec.get(this.level_field_name);
                
                if (
    r_level == level &&
                
    r_lft lft &&
                
    r_rgt rgt) {
                    
    result.push(rec);
                }
            }
            
            return 
    result;
        }
    });

    Ext.ux.maximgb.treegrid.GridView Ext.extend(Ext.grid.GridView, {
        
        
    // private
        
    breadcrumbs_elnull,
        
    forceFitfalse,
        
    unrendered: {},
        
        
    // private - overriden
        
    initTemplates: function(){
            
            var 
    ts this.templates || {};
            
            
    ts.master = new Ext.Template(
                
    '<div class="x-grid3" hidefocus="true">'
                
    '<div class="x-grid3-viewport">'
                
    '<div class="x-grid3-header">'
                
                
    // Breadcrumbs
                
    '<div class="x-grid3-header-inner">'
                
    '<div class="x-grid3-header-offset">'
                
    '<div class="ux-maximgb-treegrid-breadcrumbs"> </div>'
                
    '</div>'
                
    '</div>'
                
    '<div class="x-clear"></div>'
                
    // End of breadcrumbs
          
                // Header
                
    '<div class="x-grid3-header-inner">',
                
    '<div class="x-grid3-header-offset">{header}</div>',
                
    '</div>'
                
    '<div class="x-clear"></div>'
                
                
    // End of header
                 
    '</div>'
                
                
    // Scroller
                 
    '<div class="x-grid3-scroller">'
                
    '<div class="x-grid3-body">{body}</div>'
                
    '<a href="#" class="x-grid3-focus" tabIndex="-1"></a>'
                
    '</div>'
                
                
    // End of scroller
                 
    '</div>'
                
                
    '<div class="x-grid3-resize-marker"> </div>'
                
    '<div class="x-grid3-resize-proxy"> </div>',
                
    '</div>'
            
    );
            
            
    ts.row = new Ext.Template(
                
    '<div class="x-grid3-row {alt} ux-maximgb-treegrid-level ux-maximgb-treegrid-level-{level}" style="{tstyle} {display_style}" rowIndex="{rowIndex}">'
                
    '<table class="x-grid3-row-table" border="0" cellspacing="0" cellpadding="0" style="{tstyle}">'
                
    '<tbody>'
                
    '<tr>{cells}</tr>'
                (
    this.enableRowBody 
                    
    '<tr class="x-grid3-row-body-tr" style="{bodyStyle}">' +
                    
    '<td colspan="{cols}" class="x-grid3-body-cell" tabIndex="0" hidefocus="on">' +
                    
    '<div class="x-grid3-row-body">{body}</div>' +
                    
    '</td>' '</tr>' ''
                
    ), 
                
    '</tbody>'
                
    '</table>'
                
    '</div>'
            
    );
            
            
    ts.cell = new Ext.Template(
                
    '<td class="x-grid3-col x-grid3-cell x-grid3-td-{id} {css}" style="{style}" tabIndex="0" {cellAttr}>'
                
    '{treeui}',
                
    '<div class="x-grid3-cell-inner x-grid3-col-{id}" unselectable="on" {attr}>{value}</div>'
                
    '</td>'
            
    );
            
            
    ts.treeui = new Ext.Template(
                
    '<div class="ux-maximgb-treegrid-uiwrap" style="width: {wrap_width}px">'
                
    '{elbow_line}'
                
    '<div style="left: {left}px" class="{cls}"> </div>'
                
    '</div>'
            
    );
            
            
    ts.elbow_line = new Ext.Template('<div style="left: {left}px" class="{cls}"> </div>');
            
            
    ts.brd_item = new Ext.Template('<a href="#" id="ux-maximgb-treegrid-brditem-{id}" class="ux-maximgb-treegrid-brditem" ext:qtip="{title}">{caption}</a>');
            
            
    this.templates ts;
            
            
    Ext.ux.maximgb.treegrid.GridView.superclass.initTemplates.call(this);
            
        },
        
        
    // private - overriden
        
    initElements: function() {
            
            var 
    Ext.Element;
            
            var 
    el this.grid.getGridEl().dom.firstChild;
            var 
    cs el.childNodes;
            
            
    this.el = new E(el);
            
            
    this.mainWrap = new E(cs[0]);
            
    this.mainHd = new E(this.mainWrap.dom.firstChild);
            
            if (
    this.grid.hideHeaders) {
                
    this.mainHd.setDisplayed(false);
            }
            
            
    // ----- Modification start
            //Original: this.innerHd = this.mainHd.dom.firstChild;
            
    this.innerHd this.mainHd.dom.childNodes[2];
            
    // ----- End of modification
            
    this.scroller = new E(this.mainWrap.dom.childNodes[1]);
            
            if (
    this.forceFit) {
                
    this.scroller.setStyle('overflow-x''hidden');
            }
            
    this.mainBody = new E(this.scroller.dom.firstChild);
            
            
    this.focusEl = new E(this.scroller.dom.childNodes[1]);
            
    this.focusEl.swallowEvent("click"true);
            
            
    this.resizeMarker = new E(cs[1]);
            
    this.resizeProxy = new E(cs[2]);
            
            
    this.breadcrumbs_el this.el.child('.ux-maximgb-treegrid-breadcrumbs');
            
    this.setRootBreadcrumbs();
            
        },
        
        
    refresh: function(headersToo) {
            
            
    /**
             * Clear unrendered map on refresh
            **/
            
    this.unrendered = {};
            
            
    Ext.ux.maximgb.treegrid.GridView.superclass.refresh.call(thisheadersToo);
            
        },
        
        
        
    // Private - Overriden
        
    doRender: function(csrsdsstartRowcolCountstripe){

            var 
    ts this.templates
                
    ct ts.cell
                
    rt ts.row
                
    last colCount 1
            
    ;
            
            var 
    tstyle 'width:' this.getTotalWidth() + ';';
            
            
    // buffers
            
    var buf = [], 
                
    cb,
                
    c
                
    = {}, 
                
    rp = {
                    
    tstyletstyle
                
    }, 
                
    r
            
    ;
            
            for (var 
    0len rs.lengthlenj++) {
                
                
    rs[j];
                
    cb = [];
                
                
    /**
                 * Expand-Render 
                 * Check if node should be rendered
                **/
                
    var r_parent       this.ds.getNodeParent(r);
                var 
    r_parent_index this.ds.indexOf(r_parent);
                
                if( 
                    
    r_parent != undefined && 
                    !
    this.ds.isExpandedNode(r_parent
                ) {
                    
                    
    this.unrendered[r_parent_index] = this.unrendered[r_parent_index] || [];
                    
    this.unrendered[r_parent_index].push(startRow);
                    
                    continue; 
                    
                }    
    // if
                
                
    var rowIndex = (startRow);
                
                for(var 
    0colCounti++) {
                    
                    
    cs[i];
                    
    p.id c.id;
                    
    p.css == 'x-grid3-cell-first ' : (== last 'x-grid3-cell-last ' '');
                    
    p.attr p.cellAttr "";
                    
                    
    p.value c.renderer(r.data[c.name], prrowIndexids);
                    
    p.style c.style;
                    
                    if (
    p.value == undefined || p.value === "") {
                        
    p.value " ";
                    }
                    
                    if (
    r.dirty && r.modified[c.name] !== undefined ) {
                        
    p.css += ' x-grid3-dirty-cell';
                    }
                    
                    
    // ----- Modification start
                    
    if (c.id == this.grid.master_column_id) {
                        
                        
    p.treeui this.renderCellTreeUI(rds);
                        
                    } else {
                        
                        
    p.treeui '';
                        
                    }
                    
                    
    // ----- End of modification
                    
    cb[cb.length] = ct.apply(p);
                    
                }
                
                var 
    alt = [];
                
                if (
    stripe && ((rowIndex 1) % == 0)) {
                    
    alt[0] = "x-grid3-row-alt"; }
                
                if (
    r.dirty) {
                    
    alt[1] = " x-grid3-dirty-row"; }
                
                
    rp.cols colCount;
                
                if (
    this.getRowClass) {
                    
    alt[2] = this.getRowClass(rrowIndexrpds); }
                
                
    rp.alt alt.join(" ");
                
    rp.cells cb.join("");
                
                
    // ----- Modification start
                
    if (!ds.isVisibleNode(r)) {
                    
                    
    rp.display_style 'display: none;';
                
                } else {
                    
                    
    rp.display_style '';
                
                }
                
                
    rp.level ds.getNodeDepth(r);
                
    rp.rowIndex rowIndex;
                
                
    // ----- End of modification
                
    buf[buf.length] = rt.apply(rp);
                
            }
            
            return 
    buf.join("");
            
        },
        
        
    processRows : function(startRowskipStripe){
            
            if(!
    this.ds || this.ds.getCount() < 1) {
                return; }
            
            var 
    rows this.getRows();
            
            
    skipStripe skipStripe || !this.grid.stripeRows;
            
            
    startRow startRow || 0;
            
            
    Ext.each(rows, function(rowidx){
                
                
    /**
                 * Expand-render
                 * Check if rows array has real-row. 
                **/
                
    if( !row ) {
                    return; }
                
                
    row.rowIndex  idx;
                
    row.className row.className.replace(this.rowClsRe' ');
                
                if (!
    skipStripe && (row.rowIndex 1) % === 0) {
                    
    row.className += ' x-grid3-row-alt'; }
                
            });
            
            
    // add first/last-row classes
            
    if(startRow === 0){
                
    Ext.fly(rows[0]).addClass(this.firstRowCls);
            }
            
            
    Ext.fly(rows[rows.length 1]).addClass(this.lastRowCls);
        },
        
        
    getCell : function(rowcol) {
                
            var 
    row this.getRow(row);
                
            if( !
    row ) {
                return; }
                
            var 
    cs Ext.get(row).querythis.cellSelector );
                
            if( 
    cs[col] == undefined ) {
                return 
    false; }
                    
            return 
    cs[col];
                
        },
        
        
    getRows : function() {
            
            if( !
    this.hasRows() ) {
                return []; }
            
            var 
    rows this.mainBody.dom.childNodes;
            
            
    /**
             * Fix of index, required for expand-render
             * Index based on rowIndex attribute, nor on dom position.
            **/
            
            
    var = [];
            
            
    Ext.each(rows, function(row) {

                
    rrow.getAttribute("rowIndex") ] = row;
                
            });
            
            return 
    r;
            
        },
            
        
    renderCellTreeUI: function(recordstore){

            var 
    tpl this.templates.treeui
                
    line_tpl this.templates.elbow_line
                
    tpl_data = {}, 
                
    recparent
                
    depth level store.getNodeDepth(record)
            ;
            
            
    tpl_data.wrap_width = (depth 1) * 16;
            
            if (
    level 0) {
                
                
    tpl_data.elbow_line '';
                
    rec record;
                
    left 0;
                
                while (
    level--) {
                    
                    
    parent store.getNodeParent(rec);
                    
                    if (
    parent) {
                        
                        if (
    store.hasNextSiblingNode(parent)) {
                            
                            
    tpl_data.elbow_line line_tpl.apply({
                                
    leftlevel 16,
                                
    cls'ux-maximgb-treegrid-elbow-line'
                            
    }) + 
                            
    tpl_data.elbow_line;
                            
                        } else {
                            
                            
    tpl_data.elbow_line line_tpl.apply({
                                
    leftlevel 16,
                                
    cls'ux-maximgb-treegrid-elbow-empty'
                            
    }) +
                            
    tpl_data.elbow_line;
                            
                        }
                        
                    } else {    
                        
                        throw [
                            
    "Tree inconsistency can't get level "
                            
    level 1
                            
    " node(id="rec.id") parent."
                        
    ].join("");
                    
                    }
                     
                    
    rec parent;
                    
                }
            }
            if (
    store.isLeafNode(record)) {
                
                if (
    store.hasNextSiblingNode(record)) {
                    
                    
    tpl_data.cls 'ux-maximgb-treegrid-elbow';
                    
                } else {
                    
                    
    tpl_data.cls 'ux-maximgb-treegrid-elbow-end';
                    
                }
                
            } else {
                
                
    tpl_data.cls 'ux-maximgb-treegrid-elbow-active ';
                
                if (
    store.isExpandedNode(record)) {
                    
                    if (
    store.hasNextSiblingNode(record)) {
                        
                        
    tpl_data.cls += 'ux-maximgb-treegrid-elbow-minus';
                        
                    } else {
                        
                        
    tpl_data.cls += 'ux-maximgb-treegrid-elbow-end-minus';
                        
                    }    
    // if
                    
                
    } else {
                    
                    if (
    store.hasNextSiblingNode(record)) {
                        
                        
    tpl_data.cls += 'ux-maximgb-treegrid-elbow-plus';
                        
                    } else {
                        
                        
    tpl_data.cls += 'ux-maximgb-treegrid-elbow-end-plus';
                        
                    }    
    // if
                    
                
    }    // if
                
            
    }    // if
            
            
    tpl_data.left depth 16;
            
            return 
    tpl.apply(tpl_data);
            
        },
        
        
    // Private
        
    getBreadcrumbsEl: function(){
            
            return 
    this.breadcrumbs_el;
            
        },
        
        
    // Private
        
    expandRow: function(recordinitial){
            
            var 
    ds this.dsilenrowpmelchildrenindexchild_index;
            
            if (
    typeof record == 'number') {
                
                
    index record;
                
    record ds.getAt(index);
                
            } else {
                
                
    index ds.indexOf(record);
                
            }
            
            
    row this.getRow(index);
            
            if( !
    row ) {
                return; }

            
    /**
             * Render child rows on expansion
            **/
            
    if( this.unrendered[index] != undefined ) {
                
                var 
    view this;
                var 
    childs_rows this.unrendered[index];
                var 
    childs_rows_html "";
                
                
    Ext.each(childs_rows, function(child_row) {
                    
                    
    childs_rows_html += view.renderRows(child_rowchild_row);
                    
                });
                
                
    Ext.DomHelper.insertHtml('afterEnd'rowchilds_rows_html);
                
                var 
    rows view.getRows();
                
                
    // Setup rowindex
                
    Ext.each(childs_rows, function(child_row) {
                    
    rows[child_row].rowIndex child_row; });
                
                
    delete this.unrendered[index];
                
            }    
    // if
            
            
    pmel Ext.fly(row).child('.ux-maximgb-treegrid-elbow-active');
            
            if (
    pmel) {
                
                if (
    ds.hasNextSiblingNode(record)) {
                    
    pmel.removeClass('ux-maximgb-treegrid-elbow-plus');
                    
    pmel.removeClass('ux-maximgb-treegrid-elbow-end-plus');
                    
    pmel.addClass('ux-maximgb-treegrid-elbow-minus');
                } else {
                    
    pmel.removeClass('ux-maximgb-treegrid-elbow-plus');
                    
    pmel.removeClass('ux-maximgb-treegrid-elbow-end-plus');
                    
    pmel.addClass('ux-maximgb-treegrid-elbow-end-minus');
                }
                
                if (
    ds.isVisibleNode(record)) {
                    
                    
    children ds.getNodeChildren(record);
                    
                    for (
    0len children.lengthleni++) {
                        
                        
    child_index ds.indexOf(children[i]);
                        
    row this.getRow(child_index);
                        
                        if( !
    row) {
                            continue; }
                        
                        
    Ext.fly(row).setStyle('display''block');
                        
                        if (
    ds.isExpandedNode(children[i])) {
                            
    this.expandRow(child_index); }
                        
                    }
                }
            }
        },
        
        
    collapseRow: function(record) {
            
            var 
    ds this.dsilenchildrenrowindex;
            
            if (
    typeof record == 'number') {
                
                
    index record;
                
    record ds.getAt(index);
                
            } else {
                
                
    index ds.indexOf(record);
                
            }    
    // if
            
            
    row  this.getRow(index);
            
    pmel Ext.fly(row).child('.ux-maximgb-treegrid-elbow-active');
            
            if (
    pmel) {
                
                if (
    ds.hasNextSiblingNode(record)) {
                    
                    
    pmel.removeClass('ux-maximgb-treegrid-elbow-minus');
                    
    pmel.removeClass('ux-maximgb-treegrid-elbow-end-minus');
                    
    pmel.addClass('ux-maximgb-treegrid-elbow-plus');
                    
                } else {
                    
                    
    pmel.removeClass('ux-maximgb-treegrid-elbow-minus');
                    
    pmel.removeClass('ux-maximgb-treegrid-elbow-end-minus');
                    
    pmel.addClass('ux-maximgb-treegrid-elbow-end-plus');
                    
                }    
    // if
                
                
    children ds.getNodeChildren(record);
                
                for (
    0len children.lengthleni++) {
                    
                    
    index ds.indexOf(children[i]);
                    
    row   this.getRow(index);

                    if( !
    row) {
                        continue; }
                        
                    
    Ext.fly(row).setStyle('display''none');
                    
    this.collapseRow(index);
                    
                }    
    // for
                
            
    }    // if
            
        
    },
        
        
    /**
         * @access private
         */
        
    initData: function(dscm){
            
            
    Ext.ux.maximgb.treegrid.GridView.superclass.initData.call(thisdscm);
            
            if (
    this.ds) {
                
    this.ds.un('activenodechange'this.onStoreActiveNodeChangethis);
                
    this.ds.un('expandnode'this.onStoreExpandNodethis);
                
    this.ds.un('collapsenode'this.onStoreCollapseNodethis);
            }
            
            if (
    ds) {
                
    ds.on('activenodechange'this.onStoreActiveNodeChangethis);
                
    ds.on('expandnode'this.onStoreExpandNodethis);
                
    ds.on('collapsenode'this.onStoreCollapseNodethis);
            }
            
            
            
        },
            
        
    onStoreActiveNodeChange: function(storeold_rcnew_rc){
            var 
    parentsilenrecitems = [], ts this.templates;
            
            if (
    new_rc) {
                
    parents this.ds.getNodeAncestors(new_rc), parents.reverse();
                
    parents.push(new_rc);
                
                for (
    0len parents.lengthleni++) {
                    
    rec parents[i];
                    
    items.push(ts.brd_item.apply({
                        
    idrec.id,
                        
    titlethis.grid.i18n.breadcrumbs_tip,
                        
    captionrec.get(this.cm.getDataIndex(this.cm.getIndexById(this.grid.master_column_id)))
                    }));
                }
                
                
    this.breadcrumbs_el.update(this.grid.i18n.path_separator +
                
    ts.brd_item.apply({
                    
    id'',
                    
    titlethis.grid.i18n.breadcrumbs_root_tip,
                    
    captionthis.grid.root_title
                
    }) +
                
    this.grid.i18n.path_separator +
                
    items.join(this.grid.i18n.path_separator));
            } else {
                
    this.setRootBreadcrumbs();
            }
        },
        
        
    setRootBreadcrumbs: function(){
            var 
    ts this.templates;
            
    this.breadcrumbs_el.update(this.grid.i18n.path_separator +
            
    ts.brd_item.apply({
                
    id'',
                
    titlethis.grid.i18n.breadcrumbs_root_tip,
                
    captionthis.grid.root_title
            
    }));
        },
        
        
    onLoad: function(storerecordsoptions){
            var 
    id store.getLoadedNodeIdFromOptions(options);
            if (
    id === null) {
                
    Ext.ux.maximgb.treegrid.GridView.superclass.onLoad.call(thisstorerecordsoptions);
            }
        },
        
        
    onStoreExpandNode: function(storerc){
            
    this.expandRow(rc);
        },
        
        
    onStoreCollapseNode: function(storerc){
            
    this.collapseRow(rc);
        }
    });

    Ext.ux.maximgb.treegrid.GridPanel Ext.extend(Ext.grid.GridPanel, {
        
    /**
         * @cfg {String|Integer} master_column_id Master column id. Master column cells are nested.
         * Master column cell values are used to build breadcrumbs.
         */
        
    master_column_id0,
        
        
    /**
         * @cfg {String} Root node title.
         */
        
    root_titlenull,
        
        
    /**
         * @cfg {Object} i18n I18N text strings.
         */
        
    i18nnull,
        
        
    // Private
        
    initComponent: function() {
            
            
    Ext.ux.maximgb.treegrid.GridPanel.superclass.initComponent.call(this);
            
            
    Ext.applyIf(this.i18nExt.ux.maximgb.treegrid.GridPanel.prototype.i18n);
            
            if (!
    this.root_title) {
                
    this.root_title this.title || this.i18n.root_title;
            }
            
            
    this.getSelectionModel().on('selectionchange'this.onTreeGridSelectionChangethis);
        },
        
        
    expandAllNodes: function(){
        
            var 
    store this.getStore();
            
            
    store.data.each(function(record){
                if (!
    store.isLeafNode(record) && store.isLoadedNode(record)) {
                    
    store.expandNode(record);
                }
            });
            
        },
        
        
    collapseAllNodes: function(){
        
            var 
    store this.getStore();
            
            
    store.data.each(function(record){
                if (!
    store.isLeafNode(record) && store.isLoadedNode(record)) {
                    
    store.collapseNode(record);
                }
            });
            
        },
        
        
    /**
         * Returns view instance.
         *
         * @access private
         * @return {GridView}
         */
        
    getView: function(){
            if (!
    this.view) {
                
    this.view = new Ext.ux.maximgb.treegrid.GridView(this.viewConfig);
            }
            return 
    this.view;
        },
        
        
    /**
         * @access private
         */
        
    onClick: function(e){
        
            var 
    target e.getTarget(), 
                
    view this.getView(), 
                
    row view.findRowIndex(target), 
                
    store this.getStore(), 
                
    sm this.getSelectionModel(), 
                
    record
                
    record_id
                
    do_default true
            
    ;
            
            
    // Row click
            
    if (row !== false) {
            
                if (
    Ext.fly(target).hasClass('ux-maximgb-treegrid-elbow-active')) {
                    
    record store.getAt(row);
                    if (
    store.isExpandedNode(record)) {
                        
    store.collapseNode(record);
                    } else {
                        
    store.expandNode(record);
                    }
                    
    do_default false;
                }
                
            } 
    // Breadcrumb click
     
    else if (Ext.fly(target).hasClass('ux-maximgb-treegrid-brditem')) {
                
    record_id Ext.id(target);
                
    record_id record_id.substr(record_id.lastIndexOf('-') + 1);
                if (
    record_id != '') {
                    
    record store.getById(record_id);
                    
    row store.indexOf(record);
                    
                    if (
    e.hasModifier()) {
                        if (
    store.isExpandedNode(record)) {
                            
    store.collapseNode(record);
                        } else {
                            
    store.expandNode(record);
                        }
                    } else if (
    sm.isSelected && !sm.isSelected(row)) {
                        
    sm.selectRow(row);
                    }
                } else {
                    
    sm.clearSelections();
                }
                
    e.preventDefault();
            }
            
            if (
    do_default) {
                
    Ext.ux.maximgb.treegrid.GridPanel.superclass.onClick.call(thise);
            }
        },
        
        
    /**
         * @access private
         */
        
    onMouseDown: function(e){
            var 
    target e.getTarget();
            
            if (!
    Ext.fly(target).hasClass('ux-maximgb-treegrid-elbow-active')) {
                
    Ext.ux.maximgb.treegrid.GridPanel.superclass.onMouseDown.call(thise);
            }
        },
        
        
    /**
         * @access private
         */
        
    onDblClick: function(e){
        
            var 
    target e.getTarget(), 
                
    view this.getView(), 
                
    row view.findRowIndex(target), 
                
    store this.getStore(), 
                
    sm this.getSelectionModel(), 
                
    record
                
    record_id
            
    ;
            
            
    // Breadcrumbs select + expand/collapse    
            
    if (!row && Ext.fly(target).hasClass('ux-maximgb-treegrid-brditem')) {
                
    record_id Ext.id(target);
                
    record_id record_id.substr(record_id.lastIndexOf('-') + 1);
                if (
    record_id != '') {
                    
    record store.getById(record_id);
                    
    row store.indexOf(record);
                    
                    if (
    store.isExpandedNode(record)) {
                        
    store.collapseNode(record);
                    } else {
                        
    store.expandNode(record);
                    }
                    
                    if (
    sm.isSelected && !sm.isSelected(row)) {
                        
    sm.selectRow(row);
                    }
                } else {
                    
    sm.clearSelections();
                }
            } else if (
    Ext.fly(target).hasClass('x-grid3-col-' this.master_column_id)) {
            
                
    record store.getAt(row);
                if (
    store.isExpandedNode(record)) {
                    
    store.collapseNode(record);
                } else {
                    
    store.expandNode(record);
                }
                
            }
            
            
            
            
    Ext.ux.maximgb.treegrid.GridPanel.superclass.onDblClick.call(thise);
        },
        
        
    /**
         * @access private
         */
        
    onTreeGridSelectionChange: function(smselection){
            var 
    record;
            
    // Row selection model
            
    if (sm.getSelected) {
                
    record sm.getSelected();
                
    this.getStore().setActiveNode(record);
            } 
    // Cell selection model
     
    else if (Ext.type(selection) == 'array' && selection.length 0) {
                
    record store.getAt(selection[0])
                
    this.getStore().setActiveNode(record);
            } else {  throw 
    "Unknown selection model applyed to the grid."; }
        }
    });

    Ext.ux.maximgb.treegrid.GridPanel.prototype.i18n = {
        
    path_separator' / ',
        
    root_title'[root]',
        
    breadcrumbs_tip'Click to select node, CTRL+Click to expand or collapse node, Double click to select and expand or collapse node.',
        
    breadcrumbs_root_tip'Click to select the top level node.'
    }

    /**
     * Paging toolbar for work this AbstractTreeStore.
     */
    Ext.ux.maximgb.treegrid.PagingToolbar Ext.extend(Ext.PagingToolbar, {
        
    onRender: function(ctposition){
            
    Ext.ux.maximgb.treegrid.PagingToolbar.superclass.onRender.call(thisctposition);
            
    this.updateUI();
        },
        
        
    getPageData: function(){
            var 
    total 0cursor 0;
            if (
    this.store) {
                
    cursor this.store.getActiveNodePageOffset();
                
    total this.store.getActiveNodeTotalCount();
            }
            return {
                
    totaltotal,
                
    activePageMath.ceil((cursor this.pageSize) / this.pageSize),
                
    pagestotal this.pageSize Math.ceil(total this.pageSize)
            };
        },
        
        
    updateInfo: function(){
            var 
    count 0cursor 0total 0msg;
            if (
    this.displayEl) {
                if (
    this.store) {
                    
    cursor this.store.getActiveNodePageOffset();
                    
    count this.store.getActiveNodeCount();
                    
    total this.store.getActiveNodeTotalCount();
                }
                
    msg count == this.emptyMsg String.format(this.displayMsgcursor 1cursor counttotal);
                
    this.displayEl.update(msg);
            }
        },
        
        
    updateUI: function(){
            var 
    this.getPageData(), ap d.activePageps d.pages;
            
            
    this.afterTextEl.el.innerHTML String.format(this.afterPageTextd.pages);
            
    this.field.dom.value ap;
            
    this.first.setDisabled(ap == 1);
            
    this.prev.setDisabled(ap == 1);
            
    this.next.setDisabled(ap == ps);
            
    this.last.setDisabled(ap == ps);
            
    this.loading.enable();
            
    this.updateInfo();
        },
        
        
    unbind: function(store){
            
    Ext.ux.maximgb.treegrid.PagingToolbar.superclass.unbind.call(thisstore);
            
    store.un('activenodechange'this.onStoreActiveNodeChangethis);
        },
        
        
    bind: function(store){
            
    Ext.ux.maximgb.treegrid.PagingToolbar.superclass.bind.call(thisstore);
            
    store.on('activenodechange'this.onStoreActiveNodeChangethis);
        },
        
        
    beforeLoad: function(storeoptions){
            
    Ext.ux.maximgb.treegrid.PagingToolbar.superclass.beforeLoad.call(thisstoreoptions);
            if (
    options && options.params) {
                if (
    options.params[this.paramNames.start] === undefined) {
                    
    options.params[this.paramNames.start] = 0;
                }
                if (
    options.params[this.paramNames.limit] === undefined) {
                    
    options.params[this.paramNames.limit] = this.pageSize;
                }
            }
        },
        
        
    onClick: function(which){
            var 
    store this.storecursor store store.getActiveNodePageOffset() : 0total store store.getActiveNodeTotalCount() : 0;
            
            switch (
    which) {
                case 
    "first":
                    
    this.doLoad(0);
                    break;
                case 
    "prev":
                    
    this.doLoad(Math.max(0cursor this.pageSize));
                    break;
                case 
    "next":
                    
    this.doLoad(cursor this.pageSize);
                    break;
                case 
    "last":
                    var 
    extra total this.pageSize;
                    var 
    lastStart extra ? (total extra) : total this.pageSize;
                    
    this.doLoad(lastStart);
                    break;
                case 
    "refresh":
                    
    this.doLoad(cursor);
                    break;
            }
        },
        
        
    onStoreActiveNodeChange: function(storeold_recnew_rec){
            if (
    this.rendered) {
                
    this.updateUI();
            }
        }
    });

    Ext.override(Ext.ux.maximgb.treegrid.GridPanel, {
        
    /* 
         EditorGridPanel makes some assumptions about the dom structure.
         We need to override this method as the dom structure is not exactly as expected
         */
        
    startEditing: function(rowcol){
            
    this.stopEditing();
            if (
    this.colModel.isCellEditable(colrow)) {
                
    this.view.ensureVisible(rowcoltrue);
                var 
    this.store.getAt(row);
                var 
    field this.colModel.getDataIndex(col);
                var 
    = {
                    
    gridthis,
                    
    recordr,
                    
    fieldfield,
                    
    valuer.data[field],
                    
    rowrow,
                    
    columncol,
                    
    cancelfalse
                
    };
                if (
    this.fireEvent("beforeedit"e) !== false && !e.cancel) {
                    
    this.editing true;
                    var 
    ed this.colModel.getCellEditor(colrow);
                    if (!
    ed.rendered) {
                        
    ed.render(this.view.getEditorParent(ed));
                    }
                    (function(){ 
    // complex but required for focus issues in safari, ie and opera
                        
    ed.row row;
                        
    ed.col col;
                        
    ed.record r;
                        
    ed.on("complete"this.onEditCompletethis, {
                            
    singletrue
                        
    });
                        
    ed.on("specialkey"this.selModel.onEditorKeythis.selModel);
                        
    this.activeEditor ed;
                        var 
    this.preEditValue(rfield);
                        
    /* gd */
                        
    var dom this.view.getCell(rowcol).firstChild;
                        var 
    masterColumnIndex this.colModel.findColumnIndex(this.master_column_id);
                        if (
    col == masterColumnIndex) {
                            var 
    el Ext.get(dom);
                            
    dom el.next();
                        }
                        
    ed.startEdit(domv);
                        
    /* end gd */
                    
    }).defer(50this);
                }
            }
        },
        
    onTreeGridSelectionChange: function(smselection){
            if (!
    selection && !sm.getSelected) {
                
    this.getStore().setActiveNode(null);
                return;
            }
            var 
    record;
            
    // Row selection model
            
    if (sm.getSelected) {
                
    record sm.getSelected();
                
    this.getStore().setActiveNode(record);
            } 
    // Cell selection model
     
    else {
                if (
    selection.cell) {
                    
    record this.getStore().getAt(selection.cell[0]);
                    
    this.getStore().setActiveNode(record);
                }
            }
        },
        
    onRender: function(){
            
    Ext.ux.maximgb.treegrid.GridPanel.superclass.onRender.apply(thisarguments);
            var 
    store this.store;
            if (
    this.enableDragDrop != false) {
                var 
    canDrop = function(draggedRecordoverRecord){
                    if (
    Ext.isEmpty(overRecord)) return true;
                    if (
    store.getNodeParent(draggedRecord) === overRecord) { return false; }
                    if (
    overRecord === draggedRecord) { return false; }
                    if (
    overRecord.isNew) { return false; }
                    
                    var 
    index store.getNodeAncestors(overRecord).indexOf(draggedRecord);
                    
                    return 
    index 0;
                };
                
                var 
    ddGroupId this.id '-dd-group';
                var 
    dragZone = new Ext.grid.GridDragZone(this, {
                    
    ddGroupddGroupId
                
    });
                var 
    dropZone = new Ext.dd.DropZone(this.getView().scroller, {
                    
    ddGroupddGroupId,
                    
    notifyOver: function(ddevtdata){
                        var 
    cls this.dropNotAllowed;
                        
                        var 
    draggedRecord dd.dragData.selections[0];
                        
                        var 
    target evt.getTarget();
                        var 
    rowIndex this.getView().findRowIndex(target);
                        
                        var 
    overRecord this.getStore().getAt(rowIndex);
                        
                        if (
    canDrop(draggedRecordoverRecord)) {
                            
    cls Ext.dd.DropZone.prototype.dropAllowed;
                        }
                        
                        return 
    cls;
                    }
    .
    createDelegate(this)                ,
                    
    notifyDrop: function(ddevtdata){
                        var 
    draggedRecord dd.dragData.selections[0];
                        
                        var 
    target evt.getTarget();
                        var 
    rowIndex this.getView().findRowIndex(target);
                        
                        var 
    overRecord this.getStore().getAt(rowIndex);
                        
                        var 
    candrop canDrop(draggedRecordoverRecord);
                        
                        if (
    candrop) {
                            if (
    overRecord) {
                            
                                var 
    fn = function(){
                                    var 
    store this.getStore();
                                    
                                    var 
    parentId overRecord.get('oid');
                                    
    draggedRecord.set(store.parent_id_field_nameparentId);
                                    
                                    
    store.applyTreeSort();
                                    
                                    
    this.getSelectionModel().deselectRange();
                                    
    this.getSelectionModel().selectRecords([draggedRecord], false);
                                    
                                    
    this.getView().refresh(true);
                                    
                                    
                                }
    .
    createDelegate(this);
                                
                                var 
    expanded this.store.isExpandedNode(overRecord);
                                if (!
    expanded) {
                                    
    this.expandAndApply(overRecordfn);
                                } else {
                                    
    fn();
                                }
                            } else {
                                var 
    store this.getStore();
                                
                                
    draggedRecord.set(store.parent_id_field_namenull);
                                
                                
    store.applyTreeSort();
                                
                                
    this.getSelectionModel().deselectRange();
                                
    this.getSelectionModel().selectRecords([draggedRecord], false);
                                
                                
    this.getView().refresh(true);
                                
                            }
                            return 
    true;
                        }
                    }
    .
    createDelegate(this)
                });
                
                
    this.dropZone dropZone;
            }
        },
        
    expandAndApply: function(anodefn){
            if (!
    anode) {
                
    fn();
                return;
            }
            
            var 
    store this.getStore();
            
            var 
    storeExpandNodeCallback store.expandNodeCallback;
            
            
    store.expandNodeCallback = function(roptionssuccess){
                
    storeExpandNodeCallback.apply(storearguments);
                
    fn();
            }
    .
    createDelegate(this);
            
    store.expandNode(anode);
            
    store.setActiveNode(anode);
            
            
    store.expandNodeCallback storeExpandNodeCallback;
        }
    });

    Ext.reg('ux-maximgb-treegrid'Ext.ux.maximgb.treegrid.GridPanel);
    Ext.reg('ux-maximgb-paging'Ext.ux.maximgb.treegrid.PagingToolbar); 

Page 44 of 44 FirstFirst ... 34424344

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •