View Full Version : Listview with xtemplate display text config var

20 Oct 2010, 4:07 AM

I am using ‘prototyping’ to give an extended listview class (pre-config class of a listview) language specific text vars that I want to use inside my xtemplate. My initial approach was to use template function, but the scope there seems to be an issue. Inside a template function the scope is the template itself. Another approach I came up with is a convert function in the fields definition. I provided a piece of code:

getLabel: function(v, record) {
switch(record.item) {
case 'A': {
return this.configVariableA;
case 'B': {
return this.configVariableB;
buildStore: function() {
return new Ext.data.JsonStore({
url : '/items/',
root : 'data',
fields : [
{name: 'label', convert: this.getLabel},
{name: 'active', mapping: 'active'},
{name: 'item', mapping: 'item'}
successProperty : 'success'

There I have the same scope issue it seems. Want I definitely not want is to return language specific data from my backend (php) framework.

My question is what is the best approach here?
Xtemplate function or convert field function

How do I solve the scope issue?

Thank very much up front.

20 Oct 2010, 4:17 AM
The prepareData method of ListView would be more appropriate for this.

20 Oct 2010, 6:29 AM
Indeed it is :)

// public override

prepareData: function(data, ri, record) {
switch(data.item) {
case 'A' : { data.label = this.ownerCt.configVariableA; break; }
case 'B' : { data.label = this.ownerCt.configVariableB; break; }
return data;

My listview has a panel as a wrapper so I still need to access it’s owner, but your solution is working like a charm. I was seriously not aware of this function and it’s usage.

Thank you very much.