Flex:从给定索引的 AdvancedDataGrid 获取项目

发布于 2024-07-26 06:18:26 字数 484 浏览 1 评论 0原文

我有一个 AdvancedDataGrid 的子类,显示树状数据结构。 给定 calculateDropIndex 返回的索引,我如何获取该索引处的项目?

阅读大量代码后,似乎最不可怕的方法是:

var oldSelectedIndex:int = this.selectedIndex;
var mouseOverIndex:int = this.calculateDropIndex(event);
this.selectedItem = mouseOverIndex;
var item:* = this.selectedItem;
this.selectedIndex = oldSelectedIndex;

另一个选项似乎是在修改 iterator 属性...但是,从我看到它使用的方式来看,这也会很快变得非常哈利。

那么,如何才能在高级数据网格中的特定索引处获取项目而不发疯呢?

I've got a subclass of AdvancedDataGrid showing a tree-like data structure. How can I, given the index returned by calculateDropIndex, get the item at that index?

After reading through reams of code, it seems like the least terrible way is:

var oldSelectedIndex:int = this.selectedIndex;
var mouseOverIndex:int = this.calculateDropIndex(event);
this.selectedItem = mouseOverIndex;
var item:* = this.selectedItem;
this.selectedIndex = oldSelectedIndex;

The other option seems to be tinkering around with the iterator property... But, judging by the way I've seen it used, that will get pretty harry pretty quickly too.

So, how can I get the item at a particular index in an advanced datagrid without going insane?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

蒗幽 2024-08-02 06:18:26

你可以尝试:

// Get the dropIndex from the dragEvent
var index:int = this.calculateDropIndex(event);
// Get the itemRenderer from the index
var renderer:IListItemRenderer = this.indexToItemRenderer(index);
// Get your item from the data property of the itemRenderer
var item:Object = renderer.data;

You could try:

// Get the dropIndex from the dragEvent
var index:int = this.calculateDropIndex(event);
// Get the itemRenderer from the index
var renderer:IListItemRenderer = this.indexToItemRenderer(index);
// Get your item from the data property of the itemRenderer
var item:Object = renderer.data;
调妓 2024-08-02 06:18:26
this.dataProvider.getItemAt(calculateDropIndex(event));

浏览文档,您似乎可以使用 openNodes,它返回所有打开节点的数组,它应该与您的索引相对应?

this.dataProvider.openNodes[calculateDropIndex(event)];
this.dataProvider.getItemAt(calculateDropIndex(event));

Looking through the docs, it seems you may be able to use openNodes, which returns an Array of all open nodes, which should correspond with your index?

this.dataProvider.openNodes[calculateDropIndex(event)];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文