View Full Version : Setting up new XTemplate on itemTpl

1 Jun 2013, 1:13 AM
Am i doing this right?

itemTpl: new Ext.XTemplate ('<div>{executionStatus} (<tpl>{count:this.getCount}</tpl>)</div>', {
getCount: function() {
var TCL = Ext.getStore("TCList");
var status = ['Pass', 'Fail', 'NC', 'NR', 'NA'];

TCL.findBy(function(rec) {

for (var a = 0; a < 5; a++){ //This will loop for the status array
var count = 0;
for (var i =0; i < TCL.data.length; i++){ //This will loop according to the amount of data inside the store
if (rec.get('type') === status[a]){
return count;
} //End of getCount function

I want to show the number of data available for the specific executionStatus on the list..

For example, i want the list to look like this (executionStatus = NOT START, ON TEST, DONE, PENDING FOR TEST)

DONE (3)

But somehow i couldn't get the number to show beside the executionStatus.

Am i doing it right in the code above?

2 Jun 2013, 9:41 PM
What if instead of "(<tpl>{count:this.getCount}</tpl>)" you did "({[this.getCount(values)]})"?

3 Jun 2013, 4:51 AM
I think i did that too, because i tried so many different possible XTemplate that looked like logical to me.

Anyway i solved it already.. instead of getting the value of count and return it to XTemplate, i just created the whole function so that it will store new fields and count to a temporary storage. And then from the temporary storage, i can easily display the data using normal itemTpl.

But i think its pretty possible to get the count value and return it to the XTemplate.. i managed to get it right for the count calculation.. the only problem is how to make the function return the right value to the right executionStatus, because there are 5 values for 5 type of executionStatus, where each value corresponds to specific executionStatus.