2013-02-28 89 views
3

有什么办法增加按钮TitlePane头(标题栏的右侧),这样我可以做一些操作(下载,删除...)如何添加按钮道场titlepane

提前致谢。

+1

在文档中,你可以提供dijit的小部件TitlePane的内容。 – springrolls 2013-03-04 14:52:43

+0

我相信,TitlePane小部件可以扩展。 – undefined 2013-03-04 20:44:28

+0

你是否得到了这个问题的答案?是否没有属性可用于声明窗体将内容添加到titlePane中? – noobcode 2015-06-16 04:51:03

回答

0

有。我能够使用在增加的dijit的创作.placeAt()方法,它做的事情,比如下面:

在index.htm的

<div id="divMap"></div> 

在main.js回调中

ready (function() { 
    var ttpMyTitlePane = new TitlePane({ 
     title: 'My Title' 
    }); 
    divMenu.appendChild(ttpMyTitlePane.domNode); 

    var btnMyButton = new Button({ 
     label: 'ButtonText', 
     onClick: function() { 
      // do stuff 
     } 
    }).placeAt(ttpMyTitlePane.domNode); 
} 
1

的dijit TitlePane头包含以下

<div class="dijitTitlePaneTitleFocus" data-dojo-attach-point="focusNode" aria-pressed="true" role="button" aria-controls="dijit_TitlePane_0_pane" tabindex="0"> 
<span data-dojo-attach-point="arrowNode" class="dijitInline dijitArrowNode" role="presentation"></span><span data-dojo-attach-point="arrowNodeInner" class="dijitArrowNodeInner">-</span><span data-dojo-attach-point="titleNode" class="dijitTitlePaneTextNode" style="user-select: none;">Rule</span> 
<span class="dijit dijitReset dijitInline dijitButton" role="presentation" widgetid="dijit_form_Button_1"> 
<span class="dijitReset dijitInline dijitButtonNode" data-dojo-attach-event="ondijitclick:__onClick" role="presentation"> 
<span class="dijitReset dijitStretch dijitButtonContents" data-dojo-attach-point="titleNode,focusNode" role="button" aria-labelledby="dijit_form_Button_1_label" tabindex="0" id="dijit_form_Button_1" style="user-select: none;"> 
<span class="dijitReset dijitInline dijitIcon dijitNoIcon" data-dojo-attach-point="iconNode"></span><span class="dijitReset dijitToggleButtonIconChar"></span> 
<span class="dijitReset dijitInline dijitButtonText" id="dijit_form_Button_1_label" data-dojo-attach-point="containerNode">x</span></span></span></span> 
</div>  

正如你看到有几个连接点,我们可以参考。

添加任何物品,甚至dijit的或自定义窗口小部件执行以下操作来放置物品后,最后在focusNode连接点(注:你必须正确地设置样式,以便项目出现在位置,你想)

 var myTitlePane = new TitlePane({ title: "TitlePane" });    

     var deleteButton = new Button({ 
      label: 'x', 
      onClick: function() { 
       //do something here like delete the titlepane 
       //alert(); 
      } 
     }); 
     deleteButton.placeAt(rulesTitlePane.focusNode); 

这会产生一种看起来像这样,

enter image description here

或者你可以取代一切,创造一切你想要个e focusNode。