DataGrid选不中行

I have noticed a strange behavior of DataGrid and Tree classes. (This extends to every subclass of ListBase.) The behavior is that under certain circumstances you will only be able to select the first item in the DataGrid or Tree.
Before figuring out what was really going on, I empirically discovered two ways of working around this problem: the first is to ensure that all the objects contained by the DataGrid or Tree are dynamic (i.e., the class is declared as a public dynamic class). The second is to implement toString().
What’s actually going on is that the DataGrid and Tree classes are keeping track of their objects by using UIDUtil.getUID(). This function tries a bunch of different approaches to generate a UID for an object. At some point it tries to assign a “uid” property to the object, which fails if the object is not a dynamic class. Its last chance attempt in the exception handler is to use toString().
The first thing it tries, by the way, is to test the object to see if it implements IUID, and if it does, it just uses that interface’s uid property. I implemented IUID to verify this, and it does work. That interface’s get uid() function gets called a lot, so it’s probably worth it to do this on all objects that we display in ListBase subclasses.

上面是在国外站点上的说明。我和一个同事在项目中也遇到类似的问题,VO类中要是有个属性名为uid,那么以这个VO列表作为数据源的Datagrid怎么选也不会选中行。

你可能感兴趣的:(datagrid)