Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Icons available for ExtJS's Panel's "tool" buttons

Tags:

extjs4

How can I set icon used in my Panel's "Title Bar"? Maybe I need to add an image myself, but if so I suppose I need to define or configure that somewhere?

{
    xtype: 'treepanel',
    title: 'Projects',
    width: 200,
    store: Ext.data.StoreManager.lookup('projects'),
    tools: [
        {
            type: 'add', // this doesn't appear to work, probably I need to use a valid class
            tooltip: 'Add project',
            handler: function() {
                console.log('TODO: Add project');
            }
        },
        ...
    ]
},
like image 592
jm2 Avatar asked May 21 '12 09:05

jm2


4 Answers

There are a set of 25 icons that can be specified by using the type config. check http://docs.sencha.com/ext-js/4-0/#!/api/Ext.panel.Tool-cfg-type

To get add symbol use

tools:[{
    type:'plus',
    tooltip: 'Add project',
    // hidden:true,
    handler: function(event, toolEl, panel){
        // Add logic
    }
}]

the specified type:'add' is not in the list

like image 187
Jom Avatar answered Jan 05 '23 00:01

Jom


If you want to add your own tool type and be able to assign it an image of your own, you can do the following:

Add a css class in your css file:

.x-tool-mytool { background-image: url(path_to_your_image_file) !important; }

Then in your tools, simply use 'mytool' as the type:

            {
                type:'mytool',
                tooltip: 'This is my tool',
                handler: function(event, toolEl, panel){
                    // my tool logic
                }
            }

Make sure that you use the same name in tool's type as you used for the css class suffix.

like image 41
Farish Avatar answered Jan 05 '23 01:01

Farish


according to the ExtJS documentation, these predefined types are available:

collapse, expand, maximize, minimize, resize, restore, move, close 

minus, plus, prev, next, pin, unpin, search, toggle, refresh

save, print, gear, help

right, left, up, down

one can enter whatever type one wants:

{type: 'YOURTYPE'}

while providing a 15px icon - or preferably icon sprites

(the background-position certainly not applies for single icons, but icon sprites):

.x-tool-img.x-tool-YOURTYPE{
   background: url('../images/custom_tool_sprites.png') no-repeat 0 0;
}

sources: Ext.panel.Tool-cfg-type, codefx.biz.

like image 27
Martin Zeitler Avatar answered Jan 04 '23 23:01

Martin Zeitler


I think you mean "set buttons used in my Panel's Title Bar", not "set icon". You can use buttons config of Panel, not tools:

buttons: [{ 
   text: 'Add',
   tooltip: 'Add project',
   handler: function() {
      console.log('TODO: Add project');
   }
}]

You can use other configurations like bbar (bottom bar), fbar (footer), tbar (top), lbar (left), rbar (right) for position the toolbar. One small notice is the config objects in buttons have the default xtype as button, so you don't need to explicitly specify them.

like image 40
U and me Avatar answered Jan 05 '23 00:01

U and me