简体   繁体   English

声明性Dijit / ContentPane中未出现程序化Dijit /树

[英]Programmatic Dijit/Tree Not Appearing in Declarative Dijit/ContentPane

Can anyone help me figure out why this works in Dojo 1.8 but not in 1.9? 谁能帮我弄清楚为什么它在Dojo 1.8中有效但在1.9中不可行?

In 1.8, the tree is placed within the “pilotTreeContainer” contentpane. 在1.8中,该树放置在“ pilotTreeContainer”内容窗格中。 In 1.9, the tree is there if you look in Firebug but visually, it just shows a loading graphic. 在1.9中,如果您在Firebug中查看,树就在那里,但从视觉上看,它只是显示一个加载图形。 pilotTreeContainer is declared in the template file for the widget that contains this code. 在包含此代码的窗口小部件的模板文件中声明了pilotTreeContainer。 All this code is in the postCreate method. 所有这些代码都在postCreate方法中。

var treeStore = lang.clone( store );

var treeModel = new ObjectStoreModel(
{
    store: treeStore,
    query: { id: 'all' },
    mayHaveChildren: function ( item ) // only ships have the unique attribute
    {
        return item.unique === undefined;
    }
} );

var pilotTree = new Tree(
{
    model: treeModel, // do we need to clone?
    autoExpand: true,
    showRoot: false,
    title: 'Click to add',
    openOnClick: true,
    getDomNodeById: function ( id ) // new function to find DOM node
    {
        if ( this._itemNodesMap !== undefined && this._itemNodesMap[ id ] !== undefined && this._itemNodesMap[ id ][0] !== undefined ) {
            return this._itemNodesMap[ id ][0].domNode;
        }
        else {
            return null;
        }
    }
} );


this.pilotTree = pilotTree;

this.pilotTreeContainer.set( 'content', pilotTree );

I've tried calling startup on both tree and contentpane. 我尝试在树和contentpane上都调用启动。

Debugging the dijit/Tree code, it seesm that there is a deferred which never resolves. 调试dijit / Tree代码后,似乎有一个延迟无法解决。 It is returned from the _expandNode function when called from the _load function (when trying to expand the root node this._expandNode(rn).then ). 当从_load函数调用时(尝试扩展根节点this._expandNode(rn).then它从_expandNode函数返回。

The part that fails in dijit/Tree is this: dijit / Tree中失败的部分是这样的:

// Load top level children, and if persist==true, all nodes that were previously opened
this._expandNode(rn).then(lang.hitch(this, function(){
    // Then, select the nodes specified by params.paths[].
    this.rootLoadingIndicator.style.display = "none";
    this.expandChildrenDeferred.resolve(true);
}));

Why is the tree not showing? 为什么树不显示? What is going wrong? 怎么了?

Coming back to this (in the hope that it would be solved in Dojo 1.10), I have found a fix. 回到这个问题(希望可以在Dojo 1.10中解决),我找到了解决方法。

I abstracted the tree into its own module, adding it to the container with placeAt() instead of using this.pilotTreeContainer.set( 'content', pilotTree ); 我将树抽象到其自己的模块中,使用placeAt()将其添加到容器中,而不是使用this.pilotTreeContainer.set( 'content', pilotTree ); :

// dijit/Tree implementation for pilots
pilotTree = new PilotTree( 
{
    model: treeModel 
} );


// add to container
pilotTree.placeAt( this.pilotTreeContainer.containerNode ); 
pilotTree.startup();

then forced it to show its content within the tree's startup() method: 然后强迫它在树的startup()方法中显示其内容:

startup: function()
{
    this.inherited( arguments );

    // force show!
    this.rootLoadingIndicator.style.display = "none";
    this.rootNode.containerNode.style.display = "block";
},

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM