2013-02-28 85 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。