PDA

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



seema
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>',


'</li>',


'</ul>',



'</tpl>',


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

displayName: function (id,name) {


var searchValues=new Array();


searchValues=filterObj.pdb.user.search.filters;


var len=searchValues.length;


var filterData="";


var temp=new Array();


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


if(searchValues[i].columnRequest[1].columnName==id){


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


temp=searchValues[i].columnRequest[2].columnValues;



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


filterData=filterData+filterValues[j].displayName;


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.

Thanks

jay@moduscreate.com
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.