View Full Version : XTemplate member functions and DataViews

14 Jul 2011, 7:24 AM

Previously I had an XTemplate that was rendered to the page just using the append method. I have recently changed this to use a DataView grabbing the JSON via AJAX and the member functions I have in the template seem to have stopped working (see below for example). Do these work as the template for a DataView or do they only work if you are calling them explicitly using the apped/overwrite functions?

var vehicleTpl = new Ext.XTemplate(
'<tpl for=".">' +
"<a href='#' alt='{marque_name} {model_name} {variant}'>" +
"<div id='vehicle-{id}' class='vehicle-box'>" +
"<div class='thumb'>" +
"<tpl if='this.hasImage(image_src)'><img src='/upload/images/stock/thumbs/{image_src}' alt='{marque_name} {model_name}' /></tpl>" +
"</div>" +
"<div class='make-model'>{marque_name} {model_name} {variant}</div>" +
"<div class='vehicle-price'>&pound;{price}" +
'<tpl if="this.isPlusVat(is_plus_vat)"> +VAT</tpl>' +
"</div>" +
"</a>" +
isPlusVat: function(vat) {
return (vat == "1");
hasImage: function(imageName) {
if( imageName == undefined || imageName == null || imageName == '' ){
return false;

var vehicleList = new Ext.DataView({
store: searchStore,
tpl: vehicleTpl,
loadingText: undefined,
id: 'vehicle-list',
itemSelector: 'div.vehicle-box',
emptyText: '<p style="padding: 0px 15px;">Sorry, no results but you may like&hellp;<p>'

18 Jul 2011, 1:21 AM
Anyone able to help show me what I've done wrong here?