PDA

View Full Version : Component queries with equal sign in selector



Roman Töngi
25 Feb 2014, 1:38 AM
I have to fetch a menu item with custom attribute 'operator' unfortunately set to '='.
Attempts with &eq; '=' or \= did not work:
menu.down('menucheckitem[operator="="]');

Is there a way to mask the equal sign?

mdnaveed42
25 Feb 2014, 3:16 AM
Hi,


Ext.create('Ext.menu.Menu', {
width: 100,
height: 110,
floating: false, // usually you want this set to True (default)
renderTo: Ext.getBody(), // usually rendered by it's containing component
items: [{
xtype: 'menucheckitem',
itemId: 'equal',
text: 'Select with Text'
}, {
xtype: 'menucheckitem',
itemId: '=',
text: 'Select with Operator'
}, {
iconCls: 'add16',
text: 'icon item'
}, {
text: 'regular item'
}]
});


Ext.ComponentQuery.query('menucheckitem#equal')[0]; // first Menu Item
Ext.ComponentQuery.query('menucheckitem[itemId==]')[0]; // second Menu Item

Hope this helps you :)

Thanks,
Md Naveed
\m/

Roman Töngi
25 Feb 2014, 3:52 AM
It does not work.

var menu = Ext.widget('menu', {
items: [
{xtype: 'menucheckitem', group: 'myGroup', text: 'Less than', operator: '<'},
{xtype: 'menucheckitem', group: 'myGroup', text: 'Equal', operator: '='}
]
});

This alerts the empty Array:
alert(Ext.ComponentQuery.query('menucheckitem[operator==]', menu));

mdnaveed42
25 Feb 2014, 4:14 AM
Hi,

It is working...kindly check and confirm


Ext.create('Ext.menu.Menu', {
width: 100,
height: 110,
floating: false, // usually you want this set to True (default)
renderTo: Ext.getBody(), // usually rendered by it's containing component
items: [{
xtype: 'menucheckitem',
operator: '=',
text: 'Select with Operator'
}, {
xtype: 'menucheckitem',
operator: '+',
text: 'Select with Anoter Operator'
}]
});


Ext.ComponentQuery.query('menucheckitem[operator==]')[0]; // first Menu Item

alert(Ext.ComponentQuery.query('menucheckitem[operator==]')[0].text); // Select with Operator


Thanks,
Md Naveed
\m/

Roman Töngi
25 Feb 2014, 4:25 AM
I copied your query statement but it does not work for me. I use Ext 4.2.1.883.

mdnaveed42
25 Feb 2014, 5:21 AM
Hi,

Firstly sorry for the trouble..

I'm facing a strange issue, if i paste the code in Sencha docs editor (http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.menu.CheckItem) it is working fine.
Whereas it is not working in Sencha Fiddle (https://fiddle.sencha.com/) or Fiddle (http://jsfiddle.net/).

Regards,
Md Naveed
\m/