PDA

View Full Version : How to use List data in an 'if' comparison



ecantrel
13 Sep 2012, 7:12 AM
Can someone help me with this: I want to make a comparison between the data in the 'Product_type' field from the List 'catList' with the value 'music-video'. This (obviously?) does not work:

if({Product_type} == 'music-video') { ....

Any suggestions would be greatly appreciated.

vdaiev
13 Sep 2012, 8:14 AM
Hi,
You can do something like that:



Ext.define('TP.model.UserModel', {
extend: 'Ext.data.Model',
fields: ['producttype', 'value']
});


var store = Ext.create('Ext.data.Store', {
model: 'TP.model.UserModel',
data: [
{ producttype: 'music-video', value: 'somevalue' },
{ producttype: 'books', value: 'somevalue' },
{ producttype: 'comics', value: 'somevalue' }
]
});


store.each(function (record) {
if (record.data.producttype == 'music-video') {
// do something
}
});

ecantrel
13 Sep 2012, 2:35 PM
vdaiev, Thank you for your suggestion. I'll try it and let you know (once I correct some additional issues)