Ext中ext:CheckboxSelectionModel 的checkbox有时候不会去掉选中的方法
2010-06-22 09:38
405 查看
使用ext:CheckboxSelectionModel 有个时候莫名其妙的不能清空所选中的checkbox,即使在ext:GridPanel设置了SelectionMemory="Disabled" 属性也一样,就仿照下面的选择所有写了一个清空的。
//自动判断是否全选并选中或不选中表头的checkbox
function autoCheckGridHead(){
var hd_checker = grid.getEl().select('div.x-grid3-hd-checker'); //CompositeElementLite/CompositeElement
var hd = hd_checker.first(); //呵呵,终于搞定了,这句测了好久,才找对对象;
if(hd != null){
if(grid.getSelectionModel().getSelections().length != grid.getStore().getCount()){ //没有全选的话
//清空表格头的checkBox
if(hd.hasClass('x-grid3-hd-checker-on')){
hd.removeClass('x-grid3-hd-checker-on'); //x-grid3-hd-checker-on
//grid.getSelectionModel().clearSelections();
}
}else{
if(grid.getStore().getCount() == 0){ //没有记录的话清空;
return;
}
hd.addClass('x-grid3-hd-checker-on');
grid.getSelectionModel().selectAll();
}
}
}
上面这个是网上常见的选择所有的checkbox方法,但目前有需要,就是选中之后不能自动去掉所选中的checkbox,所以做了如下的:
function ClearChecker()
{
var grid=Ext.getCmp("GridResourceList");
var hd_checker = grid.getEl().select('div.x-grid3-hd-checker'); //CompositeElementLite/CompositeElement
var hd = hd_checker.first();
if(hd != null){
hd.addClass('x-grid3-hd-checker-on');
hd.removeClass('x-grid3-hd-checker-on'); //这个是去掉上面标题中的
grid.getSelectionModel().clearSelections();//这个是清空所有的,为不选中
//grid.getSelectionModel().selectAll();这个是设置选中所有的
}
}
前台调用直接调用函数就可以了,如果要在cs中调用也简单,在你操作的方法中
ScriptManager1.ScriptManager.AddScript("ClearChecker();");
其中ScriptManager1是页面
<ext:ScriptManager ID="ScriptManager1" runat="server" AjaxMethodNamespace="ResourceAuditNamespace">
</ext:ScriptManager>
的ID;
//自动判断是否全选并选中或不选中表头的checkbox
function autoCheckGridHead(){
var hd_checker = grid.getEl().select('div.x-grid3-hd-checker'); //CompositeElementLite/CompositeElement
var hd = hd_checker.first(); //呵呵,终于搞定了,这句测了好久,才找对对象;
if(hd != null){
if(grid.getSelectionModel().getSelections().length != grid.getStore().getCount()){ //没有全选的话
//清空表格头的checkBox
if(hd.hasClass('x-grid3-hd-checker-on')){
hd.removeClass('x-grid3-hd-checker-on'); //x-grid3-hd-checker-on
//grid.getSelectionModel().clearSelections();
}
}else{
if(grid.getStore().getCount() == 0){ //没有记录的话清空;
return;
}
hd.addClass('x-grid3-hd-checker-on');
grid.getSelectionModel().selectAll();
}
}
}
上面这个是网上常见的选择所有的checkbox方法,但目前有需要,就是选中之后不能自动去掉所选中的checkbox,所以做了如下的:
function ClearChecker()
{
var grid=Ext.getCmp("GridResourceList");
var hd_checker = grid.getEl().select('div.x-grid3-hd-checker'); //CompositeElementLite/CompositeElement
var hd = hd_checker.first();
if(hd != null){
hd.addClass('x-grid3-hd-checker-on');
hd.removeClass('x-grid3-hd-checker-on'); //这个是去掉上面标题中的
grid.getSelectionModel().clearSelections();//这个是清空所有的,为不选中
//grid.getSelectionModel().selectAll();这个是设置选中所有的
}
}
前台调用直接调用函数就可以了,如果要在cs中调用也简单,在你操作的方法中
ScriptManager1.ScriptManager.AddScript("ClearChecker();");
其中ScriptManager1是页面
<ext:ScriptManager ID="ScriptManager1" runat="server" AjaxMethodNamespace="ResourceAuditNamespace">
</ext:ScriptManager>
的ID;
相关文章推荐
- Ext中ext:CheckboxSelectionModel 的checkbox有时候不会去掉选中的方法
- extjs grid的Ext.grid.CheckboxSelectionModel默认选中解决方法
- [转]extjs grid的Ext.grid.CheckboxSelectionModel默认选中解决方法
- 关于ext中使用 Ext.grid.CheckboxSelectionModel作为选择框如何保存选中记录的解决方法。
- 【转】Ext的CheckboxSelectionModel默认选中
- 【解决方案】Ext.grid.CheckboxSelectionModel 实现锁住指定行不被选中
- Ext的CheckboxSelectionModel默认选中
- Ext的CheckboxSelectionModel默认选中
- Ext的CheckboxSelectionModel默认选中
- Ext.grid.CheckboxSelectionModel复选框设置某行不可以选中
- Ext.Net 和 ExtJs 通用的CheckboxSelectionModel默认加载项 绑定方法
- Ext.grid.CheckboxSelectionModel去除全选框
- EXT CheckboxSelectionModel 多选效果以及获取选定值
- Ext.selection.CheckboxModel全选失效问题
- Ext中CheckboxSelectionModel让其符合某一条件行不能被选中
- Ext.grid.CheckboxSelectionModel()勾选不上
- 去掉extjs中CheckboxSelectionModel的全选框
- 修改ext中拖拽和CheckboxSelectionModel冲突的有关问题
- Ext中CheckboxSelectionModel让其符合某一条件行不能被选中
- Ext.Net中CheckboxSelectionModel的动态隐藏(显示),一定条件下的隐藏(不让选择),获得多选栏位的信息,及后台控件的动态创建