PDA

View Full Version : [CLOSED] List.groupTpl cannot accept an XTemplate



teedev
9 Nov 2012, 7:04 AM
It seems that this bug is still there in Sencha Touch 2.x
http://www.sencha.com/forum/showthread.php?136512-List.groupTpl-cannot-accept-an-XTemplate
The solution there isn't working for 2.x. So I need an other solution. Thanks!

mitchellsimoens
9 Nov 2012, 8:42 AM
List does not have a groupTpl config. The header text is what you return in the store groupers

teedev
9 Nov 2012, 10:06 AM
The header text is what you return in the store groupers

Where can I find informations about the "header text"? Under
http://docs.sencha.com/touch/2-0/#!/api/Ext.dataview.List I can't find any information about headers.

Every group in my List must have an different group header which is set by 2 functions (getGroupTitle and getGroupScore). In ST1 I used this


groupTpl : new Ext.XTemplate('<tpl for=".">',
'<div class="x-list-group x-group-{id}">',
'<h3 class="x-list-header">{group:this.getGroupTitle}</h3>',
'<div class="x-list-group-items">', '{items}', '</div>', '
<div style="padding:4px 14px;">' + 'Total section score' +
':&nbsp;&nbsp;<div style="float:right;">{group:this.getGroupScore}</div></div>', '</div>', '</tpl>', {
getGroupTitle : function(group) {
return .....
},
getGroupScore : function(group) {
return .....
}
}),

How to archive the same thing with ST 2x? I would be great if you can give me a short code example.

mitchellsimoens
9 Nov 2012, 10:20 AM
Check out the examples. You return a string and it's grouped off that.

teedev
10 Nov 2012, 12:44 AM
Check out the examples. You return a string and it's grouped off that.

Thanks, I've already seen the examples. They doesn't help me. Because they are too simple.
My store has 3 fields: group, question, score.

I want to group the list items by the "group" field. But the content of this "group" field should'n be displayed. I want to display a string that depends on the content of the group field. In my code above it is delieverd by the getGroupTitle() function.

And I want to display a total score of the score field of all items in the same group. This score is calculated by a funtion and is different in every group. In my code above it is the getGroupScore() function.

It should look like this:

MyGroupText1: total section score: 5
....items (Question, score)....
MyGroupText2: total section score: 7
....items (Question, score)....
MyGroupText3: total section score: 4
....items (Question, score)....

How to do this?