-
26 Mar 2012 11:52 AM #1
tpl and renderTpl use cases
tpl and renderTpl use cases
Hi,
I'm confused about the role of the tpl and renderTpl attributes. They can't be use together so i guess they do similar things.
For what i know- tpl works with data and renderTpl. we can overwrite the content with the component's update method.
- renderTpl works with renderData. We can overwrite the content with the XTemplate's overwrite method.
For instance, i want to create a custom component with some internal dom structure. I want to give the user the opportunity to update the content at runtime. Tpl seems fine. Am i wrong?
i find nothing on the forum but if i am wrong feel free to redirect me.
Thanks.
-
27 Mar 2012 8:49 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,710
- Vote Rating
- 436
renderTpl affects the component's structure. tpl affects the inner html when passing in the data config (or using the update method).
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
28 Mar 2012 4:56 AM #3
Hi,
thanks but it does not help me that much. I'm currently looking at some Ext component source code to get the concept and come to the point that renderTpl is the solution for custom component.
Besides that, i obviously miss something. Do you have a simple example where tpl could be used with renderTpl. The only example i can find so far with tpl is:
Ext.create('Ext.Component', {
renderTo: Ext.getBody(),
tpl: new Ext.XTemplate(
'<div class="product">',
'<div>{name}:{desc}</div>',
'</div>'
),
data: {
name: 'Product A',
desc: 'Lorem ipsum dolor sit amet'
}
});
Thanks again.
-
28 Mar 2012 5:46 AM #4
is it the way to use it.
In my custom component, the inner structure is defined with renderTpl and populates with renderData.
Then when i instanciate the component, tpl give the opportunity to add a formatted html text inside my inner div. It's up to me to copy inside the component the generated content at the right place inside the inner div.Code:renderTpl:[ '<div>', '<div id="inner">', '{text}', '</div>', '</div>]
Am i right or i definitely miss something?Code:Ext.create('My.custom.Component', { data: {value:'hello world!'}, tpl: ''<div><p><b>{value}</b></p></div>" });
Thanks.


Reply With Quote