English 中文(简体)
• 如何利用Extjs代表模式,在Extjs工具bar增加工具
原标题:How to use Extjs delegate pattern to add tooltip on Extjs toolbar
  • 时间:2012-04-27 04:53:51
  •  标签:
  • extjs4

我使用“Extjs”工具,与许多纽州接触。 能够知道如何为具有代表性的县应用工具图。

最佳回答

我的工具

xtype:  toolbar ,
dock:  top ,
id:  toolbar-id ,
items: [
    {
    xtype:  button1 ,
    id:  button-id1 ,
    cls:  tb-btn ,
    qtipText:  tool tip description ,
    qtipTitle:  tool tip title 
    },
    {
    xtype:  button2 ,
    id:  button-id2 ,
    cls:  tb-btn ,
    qtipText:  tool tip description ,
    qtipTitle:  tool tip title 
    }
    ]

采用代表制法

render: function(Component, eOpts) {

    Component.tip = Ext.create( Ext.tip.ToolTip , {
        target: Component.el,
        delegate:  .tb-btn ,
        renderTo: Ext.getBody(),
        listeners: {
            beforeshow: function updateTipBody(tip) {
                var btnData = Component.getComponent(tip.triggerElement.id);
                tip.update("<div class= tol-box ><h4 class= tool-tip-title >" + btnData.qtipTitle +  </h4><p>  + btnData.qtipText + "</p></div>");
            }
        }
    });
}
问题回答

法典应当如此:

var store = Ext.create( Ext.data.ArrayStore , {
    fields: [ company ,  price ,  change ],
    data: [
        [ 3m Co ,                               71.72, 0.02],
        [ Alcoa Inc ,                           29.01, 0.42],
        [ Altria Group Inc ,                    83.81, 0.28],
        [ American Express Company ,            52.55, 0.01],
        [ American International Group, Inc. ,  64.13, 0.31],
        [ AT&T Inc. ,                           31.61, -0.48]
    ]
});

var grid = Ext.create( Ext.grid.Panel , {
    title:  Array Grid ,
    store: store,
    columns: [
        {text:  Company , flex: 1, dataIndex:  company },
        {text:  Price , width: 75, dataIndex:  price },
        {text:  Change , width: 75, dataIndex:  change }
    ],
    height: 200,
    width: 400,
    renderTo: Ext.getBody()
});

grid.getView().on( render , function(view) {
    view.tip = Ext.create( Ext.tip.ToolTip , {
        // The overall target element.
        target: view.el,
        // Each grid row causes its own seperate show and hide.
        delegate: view.itemSelector,
        // Moving within the row should not hide the tip.
        trackMouse: true,
        // Render immediately so that tip.body can be referenced prior to the first show.
        renderTo: Ext.getBody(),
        listeners: {
            // Change content dynamically depending on which element triggered the show.
            beforeshow: function updateTipBody(tip) {
                tip.update( Over company "  + view.getRecord(tip.triggerElement).get( company ) +  " );
            }
        }
    });
});

如果你想更多例子或细节,你可参看





相关问题
How to use JSON without json file?

I need to use dynamically JSON with data.TreeStore. With this component, there is proxy "config", it need a path to JSON file. My problem is, i can t write Json file in my application. I would know, ...

Dynamic Model with ExtJS 4

With ExtJS 3.x, I was able to use the "fields" property of a Store, but it seems with ExtJS 4 I have to absolutely use a Model. It s fine, but in my case, it s not a static Model, and I need to define ...

TreeNode click event on ExtJs 4

I m using ExtJS 4 (beta 3) and I have a TreePanel that is my kind of navigation menu. It is something like this: Jobs Add Job List All Jobs ... ... ... (this will be made on a permission system ...

Ext.loader not enabled Missing required?

I have some problems with Extjs4 librairie. I want to use treeEditor component. Firebug error : Error : uncaught exception: Ext.Loader is not enabled, so dependencies cannot be resolved ...

how to make a "MVC Application" with extjs 4.0 beta 3?

Is there someone here who made a MVC application using EXTJS 4 BETA 3? and works fine?? please help me how?, .. I have followed step by step here .. and @Abdel Olakara help but there is still an ...

Object function has no method defer

I m try to render a progress bar in grid (Ext JS), and get this error: Object function has no method defer What is this "magical" method? What does it do? And why is it not found? Code: renderer:...

热门标签