如何为jquery格式化程序添加select all

时间:2017-03-14 08:37:02

标签: javascript jquery

我的代码就像这样

var columnDisplay = [{
  "name": "columnId",
  "label": "Column Id",
  "type": "string",
  hidden: true,
  "width": "200",
  key: true
}, {
  "name": "columnDisplayName",
  "label": "Column Display Name",
  "type": "string",
  "visibility": true,
  "width": "200"
}, {
  "name": "visibility",
  "label": "Visibility",
  "editable": true,
  "width": "200",
  "edittype": "checkbox",
  "editoptions": {
    value: "Y:N"
  },
  "formatter": "checkbox",
  "formatoptions": {
    disabled: false
  }
}];

我调用了名为createJqgrid的函数,因为我已经提到过multiselect是真的..

我的问题是,在我的表中我有一个(visibilty)复选框的列,但我不知道如何我不能添加标题的复选框..我想让他们selectAll / deselectAll。我试图添加..但在列中它消失了,我将不得不双击它以获取列中的复选框

请帮忙!提前致谢

3 个答案:

答案 0 :(得分:0)

尝试添加jqGrid Option此键:

 multiboxonly:true

答案 1 :(得分:0)

jQuery("#list9").jqGrid({
    url:'server.php?q=2&nd='+new Date().getTime(),
    datatype: "json",
    colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'],
    colModel:[
        {name:'id',index:'id', width:55},
        {name:'invdate',index:'invdate', width:90},
        {name:'name',index:'name', width:100},
        {name:'amount',index:'amount', width:80, align:"right"},
        {name:'tax',index:'tax', width:80, align:"right"},      
        {name:'total',index:'total', width:80,align:"right"},       
        {name:'note',index:'note', width:150, sortable:false}       
    ],
    rowNum:10,
    rowList:[10,20,30],
    pager: '#pager9',
    sortname: 'id',
    recordpos: 'left',
    viewrecords: true,
    sortorder: "desc",
    **multiselect: true,**
    caption: "Multi Select Example"
});

请参阅此处的文档http://www.trirand.com/blog/jqgrid/jqgrid.html

只需要设置" multlectlect"选项" true"。

答案 2 :(得分:0)

var columnDisplay = [{
  "name": "columnId",
  "label": "Column Id",
  "type": "string",
  hidden: true,
  "width": "200",
  key: true
}, {
  "name": "columnDisplayName",
  "label": "Column Display Name",
  "type": "string",
  "visibility": true,
  "width": "200"
}, {
  "name": "visibility",
  **"label": "<input role='checkbox' type='checkbox' id='grid'>Visibility"**,
  "editable": true,
  "width": "200",
  "edittype": "checkbox",
  "editoptions": {
    value: "Y:N"
  },
  "formatter": "checkbox",
  "formatoptions": {
    disabled: false
  }
}];

我们将设置角色,类型为复选框 ..我们需要设置一个唯一的ID,以便我们可以使用该ID选择所有并取消全部..