优秀的编程知识分享平台

网站首页 > 技术文章 正文

easyui datagrid 查询会触发onUncheck问题

nanyue 2025-05-27 16:30:45 技术文章 3 ℃

datagrid 开启多选框,如果你在页面选择后,去搜索,查询刷新数据会触发onUncheck(全不选)事件;那么就不采用查询而是采用load(重载)就不会触发;

例如:做列表多选,并支持跨页、查询多选,遇到历史选中的数据能显示选中状态;

<table data-toggle="topjui-datagrid" data-options="id: 'xxxDg',showFooter:true,
                  checkOnSelect:true,onDblClickRow:doDbClickCancelCheckbox, nowrap:true,autoRowHeight:false,onCheck:function(index,row){checkFee(index,row,1)},onUncheck:function(index,row){checkFee(index,row,2)},
                 onCheckAll:function(rows){checkAllFee(rows,1)},onUncheckAll:function(rows){checkAllFee(rows,2)},onBeforeLoad:function(param){param.check_ids=$('#fee_ids').val()},
                    url:'xxx.com?xxx=xxx'">
        <thead>
        <tr>
            <th data-options="field:'for_what',title:'事由',sortable:true,width:300"></th>
           <!--        ……      -->
        </tr>
        </thead>
    </table>
<!-- 表格工具栏开始 -->
<div id="xxxDg-toolbar" class="topjui-toolbar" data-options="grid:{ type:'datagrid', id:'xxxDg'}">
    <form id="xxxDgForm" class="search-box">
        <input type="text" name="apply_username"  data-toggle="topjui-combobox"
               data-options="prompt:'申请人',width:100 ,data:[],editable:true,hasDownArrow:false,panelHeight:0,onChange:xxxDgChange">
<!--        ……      -->
        <a href="javascript:void(0)" id="xxxDgSubmit" data-toggle="topjui-menubutton"
           data-options="method:'query', iconCls:'fa fa-search',   btnCls:'topjui-btn-blue',
               form:{id:'xxxDgForm'},
               grid:{type:'datagrid','id':'xxxDg'}">查询</a>
    </form>
</div>
<script>
     //当双击一行时,取消复选框选中状态
    function doDbClickCancelCheckbox(index, row) {
        $('#xxxDg').iDatagrid('uncheckRow',index);
    }
 //当改变下拉列表值时,执行此函数
     function xxxDgChange(nv,ov) {
         $('#xxxDg').iDatagrid('load',$('#xxxDgForm').serializeObject());
         // $('#xxxDgSubmit').trigger('click')
     }            
 </script>

如果采用$('#xxxDgSubmit').trigger('click')默认查询,那么就会触发全不选事件,如果采用$('#xxxDg').iDatagrid('load',$('#xxxDgForm').serializeObject()); load重载就不会触发

最近发表
标签列表