PDA

View Full Version : How to loop through the items in Ext.menu.Menu and delete items with a specific prop



tsensuous.grace
22 Jun 2016, 4:39 PM
I'm using the Ext.menu.Menu to list items and want to loop through them to look for a specific value. Js:

new Ext.Container({
width: 560,
height: 250,
layout: 'hbox',
items: [
new Ext.menu.Menu({
items: [
{
text: 'Today',
handler: function() {
},
scope: this
}
].concat([
{
text: 'Yestaerday',
handler: function() {
},
scope: this
}, {
text: 'Month'
handler: function() {
},
scope: this
}
]).concat([
{
text: 'Year',
handler: function() {
},
scope: this
}]
})

in the above code i'm trying to remove the items whose text value is"Yestaerday and Month". How can I loop through the menu items to find the equivalent text value to be removed?thx

Gary Schlosberg
23 Jun 2016, 10:23 AM
Why put them in there in the first place? Can I ask what the use case is here?

tsensuous.grace
24 Jun 2016, 12:45 PM
This is an existing code in the appln and I dont have much control over the code sturcture. The scenarios is these menu items are concatenated together to form dropdown for a datepicker extended by "twinTriggerField" I want to display only few options for rendering purpose(the options listed in the question).