2

谁能帮我弄清楚为什么这在 Dojo 1.8 中有效但在 1.9 中无效?

在 1.8 中,树被放置在“pilotTreeContainer”内容窗格中。在 1.9 中,如果您在 Firebug 中查看,树就在那里,但在视觉上,它只是显示一个加载图形。在包含此代码的小部件的模板文件中声明了 PilotTreeContainer。所有这些代码都在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 );

我试过在树和内容窗格上调用启动。

调试 dijit/Tree 代码,似乎有一个永远不会解决的延迟。当从 _load 函数调用时(尝试扩展根节点时this._expandNode(rn).then),它从 _expandNode 函数返回。

在 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);
}));

为什么树不显示?出了什么问题?

4

1 回答 1

0

回到这个问题(希望它会在 Dojo 1.10 中得到解决),我找到了一个修复方法。

我将树抽象为它自己的模块,将其添加到容器中,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();

然后强制它在树的startup()方法中显示其内容:

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

    // force show!
    this.rootLoadingIndicator.style.display = "none";
    this.rootNode.containerNode.style.display = "block";
},
于 2015-10-09T09:04:37.353 回答