문제

After a 4.1.1 upgrade I noticed a quirky change in a way how XTemplate interprets null value. Here is an example of what XTemplate does http://jsfiddle.net/dbrin/AyJ9v/3/ (note Field 2 value) . And here is the same but interpreted by Template class: http://jsfiddle.net/dbrin/AyJ9v .

When data passed to an XTemplate contains null values string "null" is printed to the output.

If this is a bug in 4.1.1 what is the workaround if I need the use of XTemplate?

Thanks.

update: Bug was fixed in 4.1.2

도움이 되었습니까?

해결책

This workaround will work (here's the JsFiddle):

var tpl = new Ext.XTemplate("<p>Field1: {f1}, Field2: {[this.outputField( values.f2 )]} </p>",{
    outputField: function( aValue )
    {
        return aValue == null ? '' : aValue;                
    }
}).compile();

다른 팁

If you want to have condition inline.

var tpl = new Ext.XTemplate("<tpl if='f2 != null'>{f2}</tpl>" ,
<tpl if='f2 == null'></tpl>").compile();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top