2016-03-17 25 views
1

我有一個帶有標題的Ext.js容器,標題包含文本作爲其標題和圖標。用於刷新選項卡。我如何獲得該容器標題的圖標點擊事件? 我使用icon: '@Url.Content("~/Images/icon-supp.png")',獲取文本旁邊的圖標。 這裏是我的代碼:如何給Ext.js中的圖標添加點擊事件

'TabChange'也僅在選項卡被更改而不是點擊圖標時激活。

更多信息:我有一箇中心容器。林添加Ext.tab.Panel給它,它有

items: [ 
      { 
           xtype: 'container', 
           title: 'FooText', 
           id: 'FooPanel', 
           icon: '@Url.Content("~/Images/icon-refresh.png")', 
    tools: [{ 
         type: 'help', 
         handler: function(){ 
          //Doesnt hit on click of tab 
         } 
        }, { 
         itemId: 'refresh', 
         type: 'refresh', 
         hidden: true, 
         handler: function(){ 
          //Doesnt hit on click of tab 
         } 
        } 
        }], 
           listeners: { 
            activate: function() { 
             //This just hits only once when that tab gets activated./ 
             alert('you clicked me'); 
            }, 
            click:function(){//Doesnt work}, 
             }, 
            handler:function(){//Doesnt work}, 

           autoScroll: true, 

          }, 

現在我需要的是對圖像圖標點擊一個亨德爾事件。可能嗎 ?

+0

你確定是這個ExtJS的?或Ext.Net? – JChap

+0

你可以添加更多的代碼嗎? –

+0

對不起,您是否在嘗試爲視圖執行刷新按鈕?版本的extjs? –

回答

1

最後我又用在標題的HTML圖像按鈕和處理的onClick event.As這樣

title: 'fooTitle <input type="image" style="float: right;padding-left:10px; height: 15px;width:30px; " src="Images/icon-refresh.png" onclick="refreshFooTab()"></input>', 

function refreshFooTab() 
{...} 
0

如果問題是刷新標籤點擊圖標,你知道這些工具嗎?

tools: 

Ext.panel.Tool CONFIGS /實例的數組要添加到報頭工具區域。這些工具存儲爲標題容器的子組件。可以使用down和{query}以及其他組件方法訪問它們。如果collapsible設置爲true,則自動創建切換工具。

請注意,除了面板可摺疊時提供的肘節工具外,這些工具只提供可視按鈕。任何必需的功能都必須通過添加執行必要行爲的處理程序來提供。

用法示例:

tools:[{ 
    type:'refresh', 
    tooltip: 'Refresh form Data', 
    // hidden:true, 
    handler: function(event, toolEl, panelHeader) { 
     // refresh logic 
    } 
}, 
{ 
    type:'help', 
    tooltip: 'Get Help', 
    callback: function(panel, tool, event) { 
     // show help here 
    } 
}] 

顯然使用這些工具,已經有聽衆,您可以設置CSS給他們,並讓像你想的工具。

更多的信息在這裏: https://docs.sencha.com/extjs/5.1/5.1.2-apidocs/#!/api/Ext.panel.Panel-cfg-tools

+0

它不工作..我沒有看到任何有點圖標即使我指定 - 我輸入:'加'(或者其他的東西),在工具 – bharath

+0

好吧,我用的主面板的工具...並沒有什麼我期待..即時通訊使用這些圖標我的標籤上得到一個巨大的標籤有點東西..我想在我的每一個刷新圖標標籤。 – bharath

+0

可能只是使用一個html輸入標籤和handel的onClick事件..>< – bharath

相關問題