Dojo当Contentpane的内容属性为字符串时,如何获取内容属性的id

Dojo When Contentpane have the content attribute as string How to get the id of content attribute?

本文关键字:属性 何获取 获取 id 字符串 Contentpane Dojo      更新时间:2023-09-26

我正在学习通过道场编程。我想要GridContainer的id。请告诉我建议!我的代码。

 function resTab(formCount,cont){
        var tab=new dijit.layout.ContentPane({
        title:formCount,
        id:''+formCount,
        content:cont,
        class:'tab',
        closable: true
    });
    dijit.byId('tabContainer').addChild(tab); 
}
cont='<div dojoType="dojox.layout.GridContainer" class="test" doLayout="true"     id="gc'+gridCounter+'" region="center" hasResizableColumns="true" opacity="0.3"  nbZones="1" allowAutoScroll="false" withHandles="true" dragHandleClass="dijitTitlePaneTitle" minChildWidth="200" minColWidth="10"></div>';

cont有一个字符串是gridcontainer标签。如果我想找出字符串的ID值,我该怎么做?

 var selectedTab=registry.byId('tabContainer').get('selectedChildWidget');

我想解决上面的代码到应用程序。谢谢你的建议。

我假设您试图在不知道真实ID(包含gridCounter)的情况下访问GridContainer

您可以通过获取ContentPane的引用,然后使用getChildren()函数来做到这一点。

例如:

var tabs = registry.byId("tabContainer"); // Get a reference to the TabContainer
var cPane = tabs.get("selectedChildWidget"); // Get a reference to the ContentPane
var grid = cPane.getChildren()[0]; // Get a reference to the GridContainer

当然,这是假设您的GridContainer被定位为ContentPane的第一个子。

如果你只想要ID,你可以使用:

var id = grid.id;

示例:http://jsfiddle.net/JaU9v/