View Full Version : Access objects attribute in Template of Listview

19 Nov 2010, 3:30 PM
This is probably a silly question but I donīt get it.
In my view I use a Listview. This is connected to a JSONStore. The Java server send the following JSON response:

...(some more objects of type MyClass)

In the Listview that is bound to the items array there is a column that displays "attrib4". If I donīt do anything special with the column "[object Object]" is displayed. So I set the tpl property to {attrib4.name} to display "NS_PV". This works of course in other javascripts but inside the template I get the javascript error "attrib4 is not defined"
How can I access the attribute name of the object attrib4 inside a ExtJS Template?

20 Nov 2010, 6:49 AM
I found a way how it works but I canīt set it in Ext Designer. This may be caused by my bad Javascript knowledge. Can anyone help?

In the initComponent of my enclosing Viewport I set the XTemplate of the column like this (where lv is the Listview):

this.lv.columns[3].tpl = new Ext.XTemplate(
getName: function(val, record) {return val.name;}