PDA

View Full Version : [SOLVED]Conditional Template always true



lpastor
21 Aug 2009, 11:01 PM
Hello,

I use a template in a row expander and my conditional test is always true, I see all the time the word EMERGENCY.

However conditional values (emergency) can have 1, 0 or nothing, The display of emergency in the template is good.


var expander = new Ext.ux.grid.RowExpander({
tpl : new Ext.Template(
'<tpl for=".">',
{emergency}<br>',
'<tpl if="emergency == \'1\'">EMERGENCY</tpl>',
'</tpl>'
)
});I have tried :

'<tpl if="emergency == \'1\'">EMERGENCY</tpl>',
'<tpl if="emergency != \'0\'">EMERGENCY</tpl>',
'<tpl if="emergency == 1">EMERGENCY</tpl>',
'<tpl if="emergency > 0">EMERGENCY</tpl>',

It's alway true, although there is 0 or nothing.

lpastor
22 Aug 2009, 2:03 AM
I have tried an other easy test :


var userColumns = [
{header: "Titre", width: 200, sortable: true, dataIndex: 'titre_demande', renderer: function(v,params,record){
if (record.store.titre_demande == "azerty"){
return v+':<font color="#00FF00">OK</font>';
}else{
return v+':<font color="#FF0000">NOT OK</font>';
}
}}
];


I am not lucky, because this test is all the time false. Although, one of my row have titre_demande=azerty !

I don't understand where is my mistake ?

Condor
22 Aug 2009, 2:09 AM
record.store.titre_demande is wrong. It should be:
v (works because you already set the dataIndex to 'titre_demande')
record.get('titre_demande') (use this to get the value from another field than the dataIndex)
record.data.titre_demande (same as above, but not recommended)

lpastor
22 Aug 2009, 2:58 AM
great ! Thank's a lot Condor.

Laurent