0

In an ExtJS 6 classic mode application I am trying to configure a menu having both regular items and items with input fields. The idea is to let the user click normal item and then display an item where text can be edited. This is how it looks

items: [{ text : '<b>Add to Favorites</b>', iconCls : 'ico-new', hideOnClick : false, handler : 'onAddToFavorites', hidden : false, bind : { hidden : '{isEditing}' } },{ xtype : 'textfield', iconCls : 'ico-new', // ignored by ExtJS - why? selectOnFocus: true, anchor : '100%', hidden : true, bind : { hidden : '{!isEditing}' } }]; 

It works fine, however iconCls property is entirely ignored for items with xtype:'textfield'. Actually, it does not seem to affect anything but regular items.

So the question is how to make ExtJS display menu icon for items containing input fields.

3
  • Textfields don't have a config property iconCls. Search for cls in the documentaiton, there are many possibilities, try which works out for you. Commented Mar 12, 2023 at 9:57
  • "there are many possibilities" - such as? Commented Mar 13, 2023 at 11:47
  • cls, fieldCls, userCls etc. These all add extra classed to different components. Filter for "cls" under Filter members in the documentation page I linked. Commented Mar 13, 2023 at 12:22

1 Answer 1

0

For this problem, if you want to place the desired icon for each item, you should use the iconcls configuration, which displays the icon in black.

{ text : '<b>Add to Favorites</b>', iconCls : 'far fa-users',hideOnClick : false,handler : 'onAddToFavorites',hidden : false,bind : {hidden : '{isEditing}'}} 

But if you want to put the icons in different colors, you should use the cls configuration for each item and create a css or scss file with the same name in the path where the main class is defined, and use the icon content configuration. Enter to display the icon next to each item to be displayed

.icon-new{ color : red; font-family: 'Font Awesome 5 Pro'; font-size: 15px; font-weight: 200; content: '\f2f1'; top: 10px !important; right: 77px !important; }
{ text : '<b>Add to Favorites</b>', cls : 'icon-new', hideOnClick : false, handler : 'onAddToFavorites', hidden : false, bind : { hidden : '{isEditing}' } }

The third method is that all the items used in the menu have their usehtml configuration set to true. You can use html commands in the text section.

{ text : '<b><i class="far fa-tags" style="font-size:16px;color:#FFF">Add to Favorites</b>', iconCls : 'far fa-users',hideOnClick : false,handler : 'onAddToFavorites',hidden : false,bind : {hidden : '{isEditing}'}} 
Sign up to request clarification or add additional context in comments.

2 Comments

The answer looks entirely irrelevant to the question asked. The problem I am experiencing is that input fields in menus do not display icons next to them. The answer seems to mention only regular text items with which I have no problems at all. Please elaborate.
Hi Dear Mooh, Can you explain about your problem more, so I do not good understand your problem. you want set icon next to input field?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.