PDA

View Full Version : xtemplate member functions in Sencha Designer



tf.alves
20 Feb 2012, 3:57 AM
Hello all,

How can I create a member function to use with an xtemplate?
I'm defining this xtemplate directly in a list. I tried using scope:this, but it doesn't work, I guess this is because the xtemplate is being implemented directly in the base class... All I really need is to be able to define a member function to use in the xtemplate.

P.s. I'm using Sencha Touch.

Thanks.

aconran
20 Feb 2012, 7:18 AM
It's not currently possible. What i would recommend as a workaround would be to add a function to the standard set of Ext.util.Format functions and then invoke that method.

tf.alves
20 Feb 2012, 7:24 AM
I see. Where should I do that then? In the Application launch method?

Thanks ;)

aconran
20 Feb 2012, 7:31 AM
Ya, that's where I'd do it

tf.alves
20 Feb 2012, 7:33 AM
Thanks! :)

tf.alves
20 Feb 2012, 7:48 AM
Another idea... Is it possible to define the xtemplate by hand and then apply it to the list? That would solve the formatting function problem, or am I missing something?

confile
5 Jun 2012, 12:43 PM
I have the same problem any suggestions?

reproman
7 Jun 2012, 12:22 PM
Aaron,

I have a similar situation. I have a View defined with tpl that renders some text and then two hyperlinks (Edit and Delete) for each row of data. When either of the two hyperlinks are clicked, I would like to fire one of my custom events for that View control. Can you please provide some sample code of how this can be accomplished using your suggested workaround? I have my onclick handlers in place to catch the hyperlink clicks, but am not sure how to structure the other part.

Thanks!

dusoft
1 Aug 2013, 12:48 PM
Hello..

I am using sencha archiect 2.2.2 and the latest version of sencha touch 2.2.X.
Can I define xtemplate merber function to format text or other purpose..?
I created a Xtemplate member function with the "+" button in the Property window, but it's doesn't works.

Please, can I help me?

View



Ext.define('SuperPromo.view.promocion.List', {
extend: 'Ext.dataview.List',
alias: 'widget.promocionlist',


config: {
id: 'promocionList',
emptyText: 'Loading promociones...',
store: 'Promociones',
itemTpl: Ext.create('Ext.XTemplate',
'<div class="some-class">',
' <span>{[this.toUpper(values.TextField)]}%</span>',
'</div>',
{
toUpper: function(text) {
return "SOMETEXT";

},
disableFormats: true
}
)
}


});




Thanks!