How to show an icon after textfield as a "Help" to enter the values into the textfield
Solution 1
Try using Ext.form.TriggerField in place of text field.
Refer Extjs docs for reference http://extjs.cachefly.net/ext-3.4.0/docs/
For ExtJs 4.1:
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.form.field.Trigger
Solution 2
Simplest way imho is to place "help icon" at the end of label text using afterLabelTextTpl like this:
afterLabelTextTpl: '<img src="images/information.gif" class="info_image" data-qtip="your help text or even html comes here...."></img>'
Can be used with any field...
Solution 3
I've made a plugin that makes use of the afterLabelTextTpl
config of Ext.form.Labelable
which is mixined to all kinds of fields like Combobox.
Here's how to use it.
{
xtype: 'textfield',
fieldLabel: 'Some field label',
name: 'name',
plugins:[{
ptype:'afterlabelinfo',
qtip:'The text appearing after hovering over the icon'
}]
}
Here's the plugin you need.
Ext.define('Ext.ux.plugin.AfterLabelInfo', {
extend: 'Ext.AbstractPlugin',
alias: 'plugin.afterlabelinfo',
init: function (cmp) {
var me = this; // the plugin
cmp.afterLabelTextTpl = [
'<span',
' class="x-ux-plugin-afterlabelinfo"',
' data-qtip="',
Ext.util.Format.htmlEncode(me.qtip || ''),
'">',
'</span>'
].join('');
}
});
Here's some css that you need.
.x-ux-plugin-afterlabelinfo {
display: inline-block;
margin-left: 5px;
width: 12px;
height: 12px;
background-image: url(img/info-after.png) !important;
}
And the icon (right click and save as)
The result
Related videos on Youtube
Srinivas B
Updated on June 04, 2022Comments
-
Srinivas B almost 2 years
I am using Extjs 4.1
I have a form with some textfields.
I want to show a help icon beside this textfield for allowing the user to enter the correct value, while the form is being displayed.
Can any body help me in solving this.
-
Dave over 11 yearsPlease work on your rep before telling other users they shouldn't ask more questions.
-
-
Srinivas B over 11 yearsThanks for ur reply.I have tried using triggers.Works fine.But the problem is,i want to show a tooltip when i place the mouse over that icon.How can i configure a tool tip for this icon? My code for the trigger is as follows xtype: 'trigger', fieldLabel: 'Srinivas', triggerCls: 'trigger', width:190 The Cls is .x-form-trigger-wrap .trigger{background-image:url('delete.png');background-position:0 0;width:17px;height:21px;border-bottom:0px solid #b5b8c8;cursor:pointer;cursor:hand;overflow:hidden;background-repeat: no-repeat} Can u please help me in placing a tool tip.
-
AJJ over 11 years
-
Srinivas B over 11 years@Jai Can i have an icon also beside the combo box ?
-
AJJ over 11 yearsyes you can.. use tpl property of the combo. countryCombo = Ext.create('Ext.form.field.ComboBox', { displayField : 'name', valueField : 'code', grow : true, store : countryStore, queryMode : 'local', listConfig: { getInnerTpl: function() { // here you place the images in your combo var tpl = '<div>'+ '<img src="images/flags/{iso2}.png" align="left"> '+ '{name}</div>'; return tpl; } } });
-
Michal Leszczyk over 9 yearsTriggerField reports as deprecated in ExtJs 5:
[W] Ext.form.field.Trigger is deprecated. Use Ext.form.field.Text instead.