如何参考Sencha Touch XTemplate中的项目数?(How to refer to the count of items in a Sencha Touch XTemplate?)

我有一个数据视图的sencha模板,如下所示,我想在商店中插入当前数量的项目。 如何在模板或xtemplate中引用此值?

tpl: "<div class='itineraryCount'>{{count would go here}} entries</div>"

我已经尝试过XTemplate的API文档,但似乎无法找到我要找的东西。 这可能吗?

I have a sencha template for a data view like the following, where I would like to insert the current number of items in the store. How can I refer to this value in the template or xtemplate?

tpl: "<div class='itineraryCount'>{{count would go here}} entries</div>"

I've tried the API documentation for XTemplate but can't seem to find what I am looking for. Is this possible?

最满意答案

切换到使用DataView而不是普通的Panel来显示您的计数,然后您可以利用随着存储自动更改而更新的计数值,您只需将values数组的长度放入XTemplate:

new Ext.DataView({ store: YOUR_STORE, tpl: '<div>{[values.length]}</div>', itemSelector:'.item', });

Switch to using a DataView rather than a plain Panel to show your count, then you can take advantage of the count value being updated as the store changes automatically, and you can just drop in the length of the values array into your XTemplate:

new Ext.DataView({ store: YOUR_STORE, tpl: '<div>{[values.length]}</div>', itemSelector:'.item', });如何参考Sencha Touch XTemplate中的项目数?(How to refer to the count of items in a Sencha Touch XTemplate?)

我有一个数据视图的sencha模板,如下所示,我想在商店中插入当前数量的项目。 如何在模板或xtemplate中引用此值?

tpl: "<div class='itineraryCount'>{{count would go here}} entries</div>"

我已经尝试过XTemplate的API文档,但似乎无法找到我要找的东西。 这可能吗?

I have a sencha template for a data view like the following, where I would like to insert the current number of items in the store. How can I refer to this value in the template or xtemplate?

tpl: "<div class='itineraryCount'>{{count would go here}} entries</div>"

I've tried the API documentation for XTemplate but can't seem to find what I am looking for. Is this possible?

最满意答案

切换到使用DataView而不是普通的Panel来显示您的计数,然后您可以利用随着存储自动更改而更新的计数值,您只需将values数组的长度放入XTemplate:

new Ext.DataView({ store: YOUR_STORE, tpl: '<div>{[values.length]}</div>', itemSelector:'.item', });

Switch to using a DataView rather than a plain Panel to show your count, then you can take advantage of the count value being updated as the store changes automatically, and you can just drop in the length of the values array into your XTemplate:

new Ext.DataView({ store: YOUR_STORE, tpl: '<div>{[values.length]}</div>', itemSelector:'.item', });