最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to uncheck the select all checkbox in Ext.selection.CheckboxModel - Stack Overflow

programmeradmin0浏览0评论

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 badges
Add a ment  | 

3 Answers 3

Reset to default 6

I'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!

发布评论

评论列表(0)

  1. 暂无评论