gpt4 book ai didi

javascript - 查找每个 ExtJs 网格组中的项目数

转载 作者:行者123 更新时间:2023-11-30 12:06:57 24 4
gpt4 key购买 nike

我试图在每个 ExtJs 网格组中找到给我项目数的属性,这样我只能在有多个项目时折叠该组。我尝试在 grdItems 上添加监视,但无法获得显示正确值的正确属性。

var view = Ext.getCmp('Grid').getView();
var groupFeature = view.getFeature('groupSummary');
grdItems = view.getEl().query('.x-grid-group-hd');

if (grdItems.length > 0)
{
for (i = 0; i < grdItems.length; i++)
{
}
}

当我执行此 grdItems[i].children.length 时,即使有超过 1 个,它也会为每个组提供“1”。

最佳答案

这可以通过商店完成,使用 getGroups() :

Returns a collection of readonly sub-collections of your store's records with grouping applied. These sub-collections are maintained internally by the collection.

例如:

var groups = grid.getStore().getGroups();

groups.each(function(group) {
console.log(group.getGroupKey(), group.getCount());
});

工作示例:https://fiddle.sencha.com/#fiddle/1469

关于javascript - 查找每个 ExtJs 网格组中的项目数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34905181/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com