-
22 Dec 2011 1:55 AM #1
Unanswered: Tpl for in a Xtemplate for a dataview
Unanswered: Tpl for in a Xtemplate for a dataview
hi,
i have a dataview with a store and an itemTpl :
Code:{ xtype: 'dataview', id: 'ListeOriginesId', ui: 'carto-origines', scrollable: 'vertical', store: 'Origines', selectedId: null }
Code:var tpl = new Ext.XTemplate( '<tpl for=".">', '<tpl exec="this.setPourcentages(values)"></tpl>', '<div class="carto-origine-item">', '<div class="carto-origine-mask"></div>', '<div id="carto-origine-{idOrigine}" class="carto-origine-content">', '<div class="carto-origine-libelle">{libelle}</div>', ...... '<div class="carto-origine-content2-preco">', '<div class="carto-origine-content2-preco-title">Préconisations</div>', '<tpl for="preconisations">', '<div>{preconisation}</div>', '</tpl>', '</div>', '</tpl>',{ setPourcentages: function (values) { ..... }});The data of the dataview are some string like 'libelle', 'idOrigine', etc. AND an array 'preconisations' with 2 string. That's why i have a <tpl for="preconisations"> to display the preconisations.Code:ItemOrigine.setItemTpl(tpl); ItemOrigine.refresh();
My dataview is rendered with good binding for simple data ( 'libelle, idOrigine, etc....) but the tpl for="preconisations" is not working.
When i debug my store between the setItemTpl() and the .refresh() on the dataview, i can see :- ItemOrigine.getStore().data.items[0]: Ext.apply.create.Class
- data: Object
- appreciations: Array[2]
- completed: false
- idOrigine: 3
- libelle: "RC"
- maitriseReelle: 5.8
- maitriseSouhaitee: 5
- nbPrecos: 1
- nbQuestions: 0
- nbQuestionsRepondu: 0
- preconisations: Array[1]
- 0: Object
- origine_id: 3
- preconisation: "Mettre en place un engagement contractuel écrit "
- 0: Object
- data: Object
So i have my array with 1 value but tpl for is not working.
Someone can help me ? please
Thanks
- ItemOrigine.getStore().data.items[0]: Ext.apply.create.Class
-
22 Dec 2011 7:05 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,582
- Vote Rating
- 433
- Answers
- 3101
Hm... just tried myself and it's working for me.
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.
-
22 Dec 2011 7:08 AM #3

Others infos :
i have a Origine model :
and 2 others models :Code:Ext.define('PRM.model.Origine', { extend: "PRM.model.BaseModel", requires: ['PRM.model.BaseModel'], fields: [ { .... } ], associations: [ { type: 'hasMany', model: 'PRM.model.Preconisation', name: 'preconisations' }, { type: 'hasMany', model: 'PRM.model.Appreciation', name: 'appreciations' } ]
Code:Ext.define('PRM.model.Preconisation', { extend: "PRM.model.BaseModel", requires: ['PRM.model.BaseModel'], fields: [ { name: 'origine_id', type: 'integer' }, { name: 'preconisation', type: 'string' } ] , belongsTo: 'PRM.model.Origine' });
Code:Ext.define('PRM.model.Appreciation', { extend: "PRM.model.BaseModel", requires: ['PRM.model.BaseModel'], fields: [ { name: 'origine_id', type: 'integer' }, { name: 'appreciation', type: 'string' } ], belongsTo: 'PRM.model.Origine' });
-
29 Dec 2011 1:24 AM #4
'<tpl for="events">' not work to with config: {itemTpl: new Ext.XTemplate(...)
'<tpl for="events">' not work to with config: {itemTpl: new Ext.XTemplate(...)
Ext.define('groupmem.view.event.EventList', {
extend: 'Ext.List',
alias : 'widget.event_list',
cls : 'ui-listview',
config: {
itemTpl: new Ext.XTemplate(
'<tpl for=".">',
'<div data-role="list-divider" role="heading" class="ui-li ui-li-divider ui-btn ui-bar-b ui-li-has-count ui-btn-up-undefined">',
'{date}',
'<span class="ui-li-count ui-btn-up-c ui-btn-corner-all">{count}</span>',
'</div>',
'<tpl for="events">',
'<li data-theme="c" class="ui-btn ui-btn-icon-right ui-li-has-arrow ui-li ui-btn-up-c">',


Reply With Quote