PDA

View Full Version : How to use tpl with displafield in Ext JS 4.2



22 Jun 2014, 7:51 PM
Hi,

I want to use a displayfield to show attachments as links via tpl setting, but don't know how.:-?

This is the fields section of my model, the 'attachments' field would be an array:

fields: [
...
{ name: 'attachments', type: 'auto' }
]


and this is the displayfield configration I've been using to test tpl, but I get nothing displayed:

{
name: 'attachments',
fieldLabel: 'Attachments',
tpl: new Ext.XTemplate(
'<tpl foreach=".">',
'<p>id: {id}</p>',
'</tpl>'
)
}



and this is one of the 'attachments' field data
49440

Thanks for your help, any suggestion will be welcome and appreciated.

mitchellsimoens
26 Jun 2014, 6:48 AM
This would require a custom extension to handle an object, the value of the display field is only meant to accept a simple value (string/number)

26 Jun 2014, 7:23 AM
This would require a custom extension to handle an object, the value of the display field is only meant to accept a simple value (string/number)

This clarifys how the issue come.

What makes me confused is that the 'tpl' configuration is supposed to deal with objects but it can only handler string/number here.

Anyway, I think there's an alternative way to achieve my goal. Using a converted field to convert attachment array to string and then display them with renderer.

I still would like to get some hint from you that how to create such a custom extension to handler this object field, thanks!

mitchellsimoens
26 Jun 2014, 7:25 AM
The tpl is not used for the value

26 Jun 2014, 7:33 AM
The tpl is not used for the value

Ok, now I see, thank you.:))