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 复选框示例,使用DataGridTemplateColumn列,HeaderTemplate与CellTemplate,标题栏可以全选或反选所有的行
WPF DATAGRID全选全不选 源码
在DataGrid中进行复选框的操作(全选和取消)
flex4 DataGrid 头标签嵌套CheckBox按钮
flex DataGrid复选框源码 flex DataGrid复选框源码 flex DataGrid复选框源码
jeasyui-datagrid-datagrid 开发参考
DataGrid中嵌套DataGrid,修改后也适用DataGrid中嵌套DataList,DataList中嵌套DataList
flex中dataGrid全选和全不选功能
silverlight DataGrid 不修改数据显示行号
DataGrid自定义列标题 DataGrid自定义列标题 DataGrid自定义列标题 DataGrid自定义列标题 DataGrid自定义列标题
easyui datagrid 多条件筛选 可复选 过滤 例如过滤200-300 500-600 类似淘宝筛选 但允许复选
本列子不使用ToolKit(有3.5和4.0的限制),添加一个类,重写DataGrid。可以在DataGrid上下左右绑定一个DataGrid,类似Footer属性。示例可直接运行,简单易懂。 (思路:两个DataGrid(mainDG,bottomDG),bottomDG...
System.Windows.Controls.DataGrid DataGrid = dataGrid1; string file = "C:Users\\Administrator\\Desktop\\qb"; Export(DataGrid, file); } public static void Export(System.Windows.Controls.DataGrid...
需要一个对datagrid控件进行的操作,不需要别的界面,自己动手做了一个。 本例子是wpf中datagrid的增加修改,对于datagrid中的canuseraddrows=true,对当前空白行进行的添加数据,修改时,鼠标离开焦点可自动更新...
WPF中的DataGrid合并单元格,模板列内嵌套DataGrid,非真正合并
通过将DataGrid保存在.xps文件中,实现对DataGrid数据的打印
WPF DataGrid 拖拽实现
JS EasyUI DataGrid动态加载数据
一个update扩展方法 文档中一种是比较笨的方法 一次只能修改一个列而且受列编辑类型影响(比如number datetime)扩展一次编辑多列,不受编辑类型影响,没有编辑属性也可以。
2.0DataGrid嵌套DataGrid,里面的鼠标滚动响应到外部,利用自定义命令传递滚轮事件参数实现,详细效果请移步: https://blog.csdn.net/u010438205/article/details/105710794