View Full Version : xTempate, how to format title of div using xTemplate in DataView

10 Jan 2012, 8:39 PM
I'm creating a DataView. In this DataView, I have used xTemplate. My problem is, I have to generate the title of div dynamically. I have used xTemplate functions to generate title string dynamically. But I'm unable to format that string. '\n' and '<br/>' none of them is working.

Here is my code:-

var tplData = new Ext.XTemplate(

'<tpl for=".">',

'<ul><li class="{[this.getLiClass(values.id)]}">',

'<div class="thumb-wrap" title="{[this.displayName(values.id,values.name)]}" class="preview" id="{id}">',

'<a href="#">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{name}</a></div>',




'<div class="x-clear"></div>',
compiled: true,

displayName: function (id,name) {

var searchValues=new Array();


var len=searchValues.length;

var filterData="";

var temp=new Array();

for(var i=0;i<len;i++){


filterData="Applied "+name+" Filter Attributes: \n";


for(var j=0;j<temp.length;j++){


filterData=filterData+"\n ";




return filterData;



Please suggest, how to insert line breaks between returned string. Or is there any other way to dynamically populate the title of div.


24 Jan 2012, 9:02 AM
What do you mean by format?

Your code is extremely hard to read. Indentation is all over the place.