jqgrid 多选参数
时间: 2023-07-29 15:14:59 浏览: 176
在 jqGrid 中启用多选,需要设置`multiselect`参数为`true`,例如:
```
$("#grid").jqGrid({
url: "data.json",
datatype: "json",
colModel: [
{ name: "id", label: "ID", width: 100 },
{ name: "name", label: "Name", width: 200 },
{ name: "price", label: "Price", width: 100 }
],
multiselect: true, // 启用多选
rowNum: 10,
rowList: [10, 20, 30],
pager: "#pager",
height: "auto",
autowidth: true,
caption: "My first grid"
});
```
启用多选后,用户可以通过点击每一行前面的复选框来进行选择。在提交表单时,可以通过`getGridParam('selarrrow')`方法获取选中行的ID数组。例如:
```
var selectedRows = $("#grid").jqGrid('getGridParam', 'selarrrow');
console.log(selectedRows);
```
这将打印选中行的ID数组。
相关问题
jqgrid searchoptions 多选
在 jqGrid 中,可以通过`searchoptions`属性为搜索列设置选项。如果需要启用多选,可以设置`multiple`属性为`true`,例如:
```
{name: "status", label: "Status", width: 100, stype: "select",
searchoptions: {sopt: ["eq", "ne"], value: ":All;1:Active;0:Inactive", multiple: true}},
```
在上面的例子中,`status`列是一个下拉框搜索列,设置了`multiple: true`,即启用了多选。在搜索时,用户可以通过按住`Ctrl`键来进行多选。在提交表单时,可以使用`postData`参数来获取多选的值。例如:
```
$("#grid").jqGrid('setGridParam', {
postData: {
status: function() {
var selectedValues = $("#grid").jqGrid('getCol', 'status', true, 'selected');
return selectedValues.join(",");
}
}
});
```
在上面的例子中,使用`getCol`方法获取`status`列中选中的值数组,然后将数组转换为逗号分隔的字符串,作为`status`参数的值。这样,就可以将多选的值正确地提交到服务器端。
阅读全文
相关推荐















