PDA

View Full Version : Can an XTemplates have renderer



Meila
27 Apr 2010, 12:21 AM
Hi!
:-/

Is there a possibility to have an selfwritten renderer für data in xtemplates.
Suppose there is something like this:
var tpl = new Ext.XTemplate(
'<tpl for=".">',
'<div class="mycontent0">',

'<span class="mycontent1" > {content1} </span>',
'<span class="mycontent2" > {content2} </span>',
'</div>',
'</tpl>'
);

Now I want to have a renderer for the - content2, but not for the content1.
I tried to overwrite the dataview.prepareData-function, but then there is not shown anything, leaving this I at least see the content in a wrong styling.
To use style-classes does not work, because I have to change the content of the content2.

Thanks for reading an hopefully for help.

Animal
27 Apr 2010, 2:03 AM
You can specify a formatting function which must exist in Ext.util.Format

Try this on the Firebug command line



Ext.util.Format.upper = function(v){return v.toUpperCase()}; new Ext.XTemplate("{foo:upper}").apply({foo:'hello'});

Meila
27 Apr 2010, 5:36 AM
Thanks for the answer. But could you give me another hint: what is the connection to the xtemplate and renderer -question I had.

Sorry if this is a dump question, but I've it.

MaximGB
27 Apr 2010, 5:43 AM
:-/


var tpl = new Ext.XTemplate("Hello, big {name:this.upper}");
tpl.upper = function(v) {return v.toUpperCase();};
tpl.apply({name:'meila'});

Mike Robinson
27 Apr 2010, 7:09 AM
The purpose of an XTemplate, afaik, is strictly "to generate formatted-HTML" that you intend to use somewhere (else). It generates a block of text.