我想只允许在我的网格中突出显示一行。如果用户选择一行,然后选择一个新行,则只会突出显示新行(同样,多选行也会关闭)。
在尝试这样做时,我设置了这个事件:
grid.onSelectedRowsChanged.subscribe(function() { grid.setSelectedRows([1,2,3]); });
虽然看起来很有效,但它很慢(3行只能执行50行)而在chrome 13中,它会返回2个错误:
1)未捕获RangeError:超出最大调用堆栈大小 和
2)巨大的错误痕迹:
error>
c.fn.c.pushStack:23
c.each.c.fn:99
getCellNode:2277
removeCellCssStyles:1506
setCellCssStyles:1518
handleSelectedRangesChanged:925
notify:125
setSelectedRanges:72
setSelectedRows:2478
grid.onAddNewRow.subscribe.item:546
notify:125
trigger:789
handleSelectedRangesChanged:927
notify:125
setSelectedRanges:72
setSelectedRows:2478
grid.onAddNewRow.subscribe.item:546
notify:125
trigger:789
handleSelectedRangesChanged:927
notify:125
setSelectedRanges:72
setSelectedRows:2478
grid.onAddNewRow.subscribe.item:546
notify:125
trigger:789
handleSelectedRangesChanged:927
notify:125
setSelectedRanges:72
setSelectedRows:2478
grid.onAddNewRow.subscribe.item:546
notify:125
trigger:789
handleSelectedRangesChanged:927
notify:125
setSelectedRanges:72
setSelectedRows:2478
grid.onAddNewRow.subscribe.item:546
notify:125
trigger:789
handleSelectedRangesChanged:927
notify:125
setSelectedRanges:72
setSelectedRows:2478
grid.onAddNewRow.subscribe.item:546
notify:125
trigger:789
handleSelectedRangesChanged:927
notify:125
setSelectedRanges:72
setSelectedRows:2478
grid.onAddNewRow.subscribe.item:546
notify:125
trigger:789
handleSelectedRangesChanged:927
notify:125
setSelectedRanges:72
setSelectedRows:2478
grid.onAddNewRow.subscribe.item:546
notify:125
trigger:789
handleSelectedRangesChanged:927
notify:125
setSelectedRanges:72
setSelectedRows:2478
grid.onAddNewRow.subscribe.item:546
notify:125
trigger:789
handleSelectedRangesChanged:927
notify:125
setSelectedRanges:72
setSelectedRows:2478
grid.onAddNewRow.subscribe.item:546
notify:125
trigger:789
handleSelectedRangesChanged:927
notify:125
setSelectedRanges:72
setSelectedRows:2478
grid.onAddNewRow.subscribe.item:546
notify:125
trigger:789
handleSelectedRangesChanged:927
notify:125
setSelectedRanges:72
setSelectedRows:2478
grid.onAddNewRow.subscribe.item:546
notify:125
trigger:789
handleSelectedRangesChanged:927
notify:125
setSelectedRanges:72
setSelectedRows:2478
grid.onAddNewRow.subscribe.item:546
notify:125
trigger:789
handleSelectedRangesChanged:927
notify:125
setSelectedRanges:72
setSelectedRows:2478
grid.onAddNewRow.subscribe.item:546
notify:125
trigger:789
handleSelectedRangesChanged:927
notify:125
setSelectedRanges:72
setSelectedRows:2478
grid.onAddNewRow.subscribe.item:546
notify:125
trigger:789
handleSelectedRangesChanged:927
notify:125
setSelectedRanges:72
setSelectedRows:2478
grid.onAddNewRow.subscribe.item:546
notify:125
trigger:789
handleSelectedRangesChanged:927
notify:125
setSelectedRanges:72
setSelectedRows:2478
grid.onAddNewRow.subscribe.item:546
notify:125
trigger:789
handleSelectedRangesChanged:927
notify:125
setSelectedRanges:72
setSelectedRows:2478
grid.onAddNewRow.subscribe.item:546
notify:125
trigger:789
handleSelectedRangesChanged:927
notify:125
setSelectedRanges:72
setSelectedRowsslick.grid.js:2478
grid.onAddNewRow.subscribe.item:546
notify:125
trigger:789
handleSelectedRangesChanged:927
notify:125
setSelectedRanges:72
setSelectedRows:2478
grid.onAddNewRow.subscribe.item:546
notify:125
trigger:789
handleSelectedRangesChanged:927
notify:125
setSelectedRanges:72
setSelectedRows:2478
grid.onAddNewRow.subscribe.item:546
notify:125
trigger:789
handleSelectedRangesChanged:927
notify:125
setSelectedRanges:72
setSelectedRows:2478
grid.onAddNewRow.subscribe.item:546
notify:125
trigger:789
handleSelectedRangesChanged:927
notify:125
setSelectedRanges:72
setSelectedRows:2478
grid.onAddNewRow.subscribe.item:546
notify:125
trigger:789
handleSelectedRangesChanged:927
notify:125
setSelectedRanges:72
setSelectedRows:2478
grid.onAddNewRow.subscribe.item:546
notify:125
trigger:789
handleSelectedRangesChanged:927
notify:125
setSelectedRanges:72
setSelectedRows:2478
grid.onAddNewRow.subscribe.item:546
notify:125
trigger:789
handleSelectedRangesChanged:927
notify:125
setSelectedRanges:72
setSelectedRows:2478
grid.onAddNewRow.subscribe.item:546
notify:125
trigger:789
handleSelectedRangesChanged:927
notify:125
setSelectedRanges:72
setSelectedRows:2478
grid.onAddNewRow.subscribe.item:546
notify:125
trigger:789
handleSelectedRangesChanged:927
notify:125
setSelectedRanges:72
setSelectedRows:2478
grid.onAddNewRow.subscribe.item:546
notify:12
有更好的方法来实现所需的功能吗?
答案 0 :(得分:0)
最大调用堆栈是由循环函数调用引起的。
首先触发onSelectedRowsChanged
事件(可能是通过onClick),它将调用上面的函数。但是,然后您的函数调用setSelectedRows
,它将设置所选行,然后触发onSelectedRowsChanged
。这将继续发生,直到JS引擎达到最大调用堆栈然后停止(毕竟,我们不想让浏览器崩溃)。
我认为唯一的解决方案是编写自己的RowSelectionModel并在那里执行grid.setSelectedRows()。