我有一个dojox.grid.DataGrid,我想以编程方式选择一行.我正在使用setSelected()这样做,它第一次工作.但是,对于不同的行再次调用它会使前一行突出显示.此外,如果我尝试重新选择之前选择的行,则不会触发onSelected事件.但是,如果我实际上在网格中单击,它会清除:在未被突出显示和未选中之前在网格中突出显示的行.
代码如下:
if (grid.rowCount > 0 && idx < grid.rowCount) { grid.selection.setSelected(idx,true); grid.render(); }
就好像我启用了多选,但我已将网格声明为selectionMode =“single”.
<table dojoType="dojox.grid.DataGrid" id="hottablesForAppDg" autoWidth="true" autoHeight="true" selectionMode="single" onSelected="autonomics.Clusters.loadTableDetails(this)">
还有什么我需要打电话来清除之前的选择吗?
解决方法
问题解决了.您需要在当前选定的索引上调用setSelected(…,false):
if (grid.rowCount > 0 && idx < grid.rowCount) { if (grid.selection.selectedindex >= 0) { // If there is a currently selected row,deselect it Now grid.selection.setSelected(grid.selection.selectedindex,false); } grid.selection.setSelected(idx,true); grid.render(); }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。