在某一列AS3数据网格选择的行 [英] Datagrid selected row at a certain column as3

查看:300
本文介绍了在某一列AS3数据网格选择的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要得到一定的列,通过AS3所选行中的价值,我该怎么办呢?

I need to get the value of a certain column in the selected row via AS3, how can I do this?

它一直返回null当我尝试 grid.SelectedItem.text ...

It keeps returning null when I try grid.SelectedItem.text...

感谢您的帮助!我需要能够以引用列的名字,在这种情况下,ID

Thanks for the help! I need to be able to reference the column by name, in this case "ID".

编辑:这是否需要一个事件或某事?不应该有一个方法,这个内置的?你会这么认为...

Does this require an event or something? Shouldn't there be a method for this built in? You'd think so...

推荐答案

你能成为一个更具体一点?

Can you be a bit more specific ?

您可以得到所有您使用的selectedItem.yourProperty DataGrid中需要的数据。 你可以发布一个片段,可能使事情清楚了吗?

You can get get all the data you need from the DataGrid using the selectedItem.yourProperty. Can you post a snippet that might make thing clear ?

引用的名字一栏是pretty的方便:

Referencing a column by name is pretty easy:

myDataGrid.getColumnAt(myDataGrid.getColumnIndex('ID'))

中的数据是在DataGrid的dataProvider,列有其他用途。

The data is in the DataGrid's dataProvider, the column is there for other purposes.

假设你有添加到DataGrid中的ID属性:

Say you have an ID property added to the DataGrid:

var dp:DataProvider = new DataProvider();
for(var i:int = 0 ; i < 7; i++)
    dp.addItem({label:'label '+(i+1), ID:Math.random()});
myDataGrid.dataProvider = dp;

如果您已经安装的处理程序<一href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/controls/SelectableList.html#event%3Achange"相对=nofollow>更改事件,你应该能够得到你需要的数据 通过<一个href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/controls/SelectableList.html#selectedItem"相对=nofollow>将selectedItem :

If you have setup a handler for the CHANGE event, you should be able to get the data you need through the selectedItem:

myDataGrid.addEventListener(Event.CHANGE, changed);

function changed(event:Event):void {
    trace('item at index ' + myDataGrid.selectedIndex + ' has ID: ' + myDataGrid.selectedItem.ID);
}

心连心, 乔治

HTH, George

这篇关于在某一列AS3数据网格选择的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆