Flex中无法选中DataGrid组件的行

Cannot select certain rows in List component or DataGrid component

The problem is that for each item in data provider, we must get a unique ID (UID) for it, if two or more items in data provider get the same UID after call itemToUID method, then we only can select one of them and can never successful to select the rest of them. To avoid this problem, refer to the following itemToUID method to understand how Flex components generate the UID and avoid generating the same UID.
Please Note, the following method itemToUID are quoted from class ListBase of SDK source code.
We can use: copyOfOldObject= ObjectUtil.copy(oldObject) to get a new instance, then when we add the copy to the ArrayCollection which is the binding source of dataProvider, we will get different UID for each instance, then we won’t have the problem.
/**
* Determines the UID for a data provider item. All items
* in a data provider must either have a unique ID (UID)
* or one will be generated and associated with it. This
* means that you cannot have an object or scalar value
* appear twice in a data provider. For example, the following
* data provider is not supported because the value "foo"
* appears twice and the UID for a string is the string itself:
*
* <blockquote>
* <code>var sampleDP:Array = ["foo", "bar", "foo"]</code>
* </blockquote>
*
* Simple dynamic objects can appear twice if they are two
* separate instances. The following is supported because
* each of the instances will be given a different UID because
* they are different objects:
*
* <blockquote>
* <code>var sampleDP:Array = [{label: "foo"}, {label: "foo"}]</code>
* </blockquote>
*
* Note that the following is not supported because the same instance
* appears twice.
*
* <blockquote>
* <code>var foo:Object = {label: "foo"};
* sampleDP:Array = [foo, foo];</code>
* </blockquote>
*
* @param data The data provider item.
*
* @return The UID as a string.
*/
protected function itemToUID(data:Object):String
{
if (data == null)
return "null";
return UIDUtil.getUID(data);
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值