关于easyui中datagrid的idField属性

在开发中遇到过, 在datagrid中选中一条数据,然后点击datagrid自带的刷新按钮, 刷新后会默认选中所有的行.

上网查询才发现是 idField 属性没有设置对.

从一些博客中参考知

  1. 官方文档中,给出定义为: 
    Indicate which field is an identity field. 
    显示哪些字段是一个身份。—–相当于一个主键字段

  2. 定义好idField,才能使用列checkbox,getSelections才能生效,不然只能得到第一个勾选的.

var outPrint = {
    url: 'outPrint/outPrintLedgerData?isDelete=0'
    , showFooter: true
    , showHeader: true
    , singleSelect: true
    , location: 'oa_general_seal_v1_sealLedger:outPrint'
    , idField: 'id'
    , onRowContextMenu: function (e, rowIndex, rowData) {
        e.preventDefault();
        $(this).datagrid('unselectAll');
        $(this).datagrid('selectRow', rowIndex);
        $('#menu').menu('show', {
            left: e.pageX,
            top: e.pageY
        });
    }
    , enableHeaderContextMenu: true    //此属性开启表头列名称右键点击菜单
    , enableHeaderClickMenu: false //此属性开启表头列名称右侧那个箭头形状的鼠标左键点击菜单
};

参考:

https://blog.csdn.net/benben683280/article/details/78788863

https://blog.csdn.net/weixin_40009624/article/details/78843001

https://blog.csdn.net/isea533/article/details/50929752

猜你喜欢

转载自blog.csdn.net/qq_40085888/article/details/84371297