2013-08-17 90 views
0

我正在嘗試在CQ5中創建頁腳組件,其中我有4列&都是可驗證的。 但是,我們必須使列的數量不再可信,即基於從下拉列表中選擇的值,我們必須打開那些僅用於創建許多列的許多選項卡。如何隱藏和取消隱藏自動標籤取決於從下拉列表中選擇的值CQ5

我創建了一個下拉菜單,最大範圍爲6列。我知道我必須爲此配置一個監聽器,但不知道如何。要求是,如果我從下拉列表中選擇3,然後3個標籤應該來作者3列

請幫助我,我是非常重要的東西的中間。我需要解決方案很早,因爲我必須完成工作儘快

+0

你的'dialog.xml'代碼看起來像什麼?你得到了什麼錯誤?大概你在問這裏之前引用了文檔中的例子嗎? - http://dev.day.com/docs/en/cq/current/developing/widgets.html#Example%201:%20Switch%20Tabs%20Dialog – anotherdave

回答

1

我現在可能但如果是這麼晚,你仍然需要它:

您需要關閉您的下拉元素之前添加偵聽器節點:

<listeners 
    jcr:primaryType="nt:unstructured" 
    loadcontent="function(box){ //here you also need to handle the hide/unhide when the panel loads for the first time. Use this.getValue() to retrive the intial value }" 
    selectionchanged="function(box, value) { 
     for(var c=1;c<=value;c++){ 
      this.findParentByType('tabpanel').unhideTabStripItem("tab"+c); // You need to handle the opposite with hideTabStripItem("tab"+c); 
     } 
    }"/> 

然後在「loadcontent」和「selectionchange」(th ese是下拉菜單中的事件)抓取當前選定的值並使用它來隱藏/取消隱藏選項卡。在這種情況下,這些標籤將被命名爲「tab1」,「tab2」等,確保你的名字是正確的。

事件中的ExtJS爲整個對話框找到「tabpanel」容器,然後根據名稱隱藏/取消隱藏。您還可以使用「.enable()」和「.setDisabled(true)」方法設置爲啓用/禁用。只要確保先得到對該選項卡的引用即可(如「.getComponent(tabName).enable()」)。

我沒有測試這個特定的代碼,我無法從我的代碼庫中找到我的實際示例,但是這應該帶您進入正確的方向。

0
<listeners 
jcr:primaryType="nt:unstructured" 
selectionchanged="function(box, value, ischecked) { 
    //ischecked- can get weather it is selected or not 
    for(var c=1;c<=value;c++){ 
     this.findParentByType('tabpanel').unhideTabStripItem("tab"+c); 
    } 
}"/> 
相關問題