extjs checkboxselection标头不更新 [英] extjs checkboxselection header not updating

查看:118
本文介绍了extjs checkboxselection标头不更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有 CheckBoxSelectionModel 的ExtJs网格。选择标题复选框检查所有记录,取消选中该复选框可以取消选中所有记录,当然这是行为。我的网格有一个删除按钮来删除所选/所有记录,并且正常工作。

I have an ExtJs Grid with CheckBoxSelectionModel. Selecting the header checkbox checks all the records and deselecting the checkbox unchecks all the records, of course which is the behavior. My grid has a delete button to delete the selected/all records and is working fine.

现在我的问题是,当我检查标题的复选框(以便整个记录将被选中)并点击我的删除按钮,网格中的整个记录​​被删除。

Now my problem is, when I check the checkbox at the header (so that entire records will be selected) and hits my delete button, the entire records in the grid is getting deleted. But, the checkbox selection in the column header still remains as checked.

我使用了代码: grid.getSelectionModel()。 clearSelections(false); 清除选择,删除后。我猜这个代码只适用于网格中的记录,与列标题无关。有没有办法,我可以取消选中标题中的chekbox?

I used the code: grid.getSelectionModel().clearSelections(false); to clear selection, after deletion. I guess, this code is only applicable to records in the grid and has nothing to do with the column header part. Is there any way, I can deselect the chekbox in the header?

在详细的调查中,我很惊讶地知道CheckBoxSelectionModel中显示的复选框不是html复选框,但它们是图像。所以我不能在这里应用使用DOM概念取消选中复选框的想法。相反,有些CSS技巧必须完成。

On a detailed investigation, I's surprised to know that the checkbox displayed in the CheckBoxSelectionModel is not html checkboxes, but they are images. So my idea of deselecting the checkbox using the DOM concept cannot be applied here. Instead, some kinda CSS trick has to be done.

有没有人面临过这样的问题?有什么解决方案吗?
任何帮助将不胜感激。
谢谢!

Does anyone faced such an issue before? Is there any solution for this? Any help will be appreciated. Thanks!

推荐答案

将听众应用于CheckboxSelectionModel:

Apply listeners to CheckboxSelectionModel :

尝试这样:

    var sm = new Ext.grid.CheckboxSelectionModel({
    listeners : {
            selectionchange : function(){
                var recLen = Ext.getCmp('grid').store.getRange().length;
                var selectedLen = this.selections.items.length;
                if(selectedLen == recLen){
                    var view   = Ext.getCmp('grid').getView();
                    var chkdiv = Ext.fly(view.innerHd).child(".x-grid3-hd-checker")
                    chkdiv.addClass("x-grid3-hd-checker-on");
                }
            }
            ,rowdeselect : function ( sm ,rowIndex ,record) {
                var view   = Ext.getCmp('grid').getView();
                var chkdiv = Ext.fly(view.innerHd).child(".x-grid3-hd-checker")
                chkdiv.removeClass('x-grid3-hd-checker-on');
            }
    }
 });

这篇关于extjs checkboxselection标头不更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆