admin管理员组文章数量:1355542
When running a getSelectionModel().clearSelections()
on a grid that uses a Ext.selection.CheckboxModel and all rows was selected using the "select all" check box at the top of the select column, the "select all" check box remains checked.
I did a dirty hack to get around this but I wish to know if there is a cleaner way or if this is a bug.
When running a getSelectionModel().clearSelections()
on a grid that uses a Ext.selection.CheckboxModel and all rows was selected using the "select all" check box at the top of the select column, the "select all" check box remains checked.
I did a dirty hack to get around this but I wish to know if there is a cleaner way or if this is a bug.
Share Improve this question edited May 6, 2013 at 14:52 Tiago Sippert 1,3307 gold badges24 silver badges33 bronze badges asked Oct 23, 2012 at 14:39 Tommy StrandTommy Strand 1,4042 gold badges15 silver badges15 bronze badges3 Answers
Reset to default 6I'd try to put a listener on a grid ponent to track selection changes (not sure if it will help):
listeners: {
selectionchange: function(grid, selected) {
if(!selected.length) {
grid.getSelectionModel().deselectAll();
}
}
}
Btw, have you tried to do getSelectionModel().deselectAll()
? clearSelections is deprecated in ExtJS 4.1 and it's runned on view not selection model.
EDIT: After reading Vyacheslav Voronchuk's answer I did back and verified that the documentation does indeed say that clearSelection is a private function that does not send an event, thereby not notifying that the checkbox should be cleared.
.getSelectionModel().deselectAll()
is indeed the way to go.
For historical reasons I include my original dirty hack that I did to get around the problem:
var el = Ext.get("gridcolumn-1031");
el.removeCls('x-grid-hd-checker-on');
gridcolumn-1031 is the id of the div wrapping the checkbox in my app. It is randomly generated so you need to dom inspect your own to do the same dirty hack.
Disclamer! Use at your own peril.
I do not condone dirty hacks like this since it is not likely to survive auto generated id change of my grid, but it will get the app approved by my client while we wait for a more permanent solution.
For removing grid header selection:
.getSelectionModel().deselectAll()
didn't work for me because my grid is already empty.
This works though (from above hack):
var selectionHeadID = Ext.getCmp('ingameGrid').headerCt.getHeaderAtIndex(0).getId();
var el = Ext.get(selectionHeadID);
el.removeCls('x-grid-hd-checker-on');
Hope this helps!
本文标签: javascriptHow to uncheck the select all checkbox in ExtselectionCheckboxModelStack Overflow
版权声明:本文标题:javascript - How to uncheck the select all checkbox in Ext.selection.CheckboxModel - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744030739a2578857.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论