【发布时间】:2016-01-20 22:05:36
【问题描述】:
有没有一种方法可以使用类似于带有单选按钮http://www.ok-soft-gmbh.com/jqGrid/SimpleLocalGridWidthRadioButton2.htm 的复选框来获取行为 带有用于选择/取消选择全部的复选框。 行选择和该行上的复选框可能未链接,就像在带有单选按钮的示例中一样。
更新:
这是我的 sn-p:
$("#list").jqGrid({
datatype: "local",
data: mydata,
colNames: ["Client", "Date", "Amount", "Tax", "Total", "Shipped via", "Notes"],
colModel: [
{name: "name", width: 70, frozen: true},
{name: "invdate", width: 80, align: "center", sorttype: "date",
formatter: "date", formatoptions: {newformat: "d-M-Y"}, datefmt: "d-M-Y"},
{name: "amount", width: 75, formatter: "number", sorttype: "number", align: "right"},
{name: "tax", width: 55, formatter: "number", sorttype: "number", align: "right"},
{name: "total", width: 65, formatter: "number", sorttype: "number", align: "right"},
{name: "ship_via", width: 100, align: "center", formatter: "select",
edittype: "select", editoptions: {value: "FE:FedEx;TN:TNT;IN:Intim", defaultValue: "IN"}},
{name: "note", width: 70, sortable: false}
],
rowNum: 10,
rowList: [5, 10, 20],
pager: "#pager",
gridview: true,
rownumbers: true,
sortname: "invdate",
viewrecords: true,
sortorder: "desc",
caption: "Handling of changing of chechboxes in the grid",
height: "auto",
multiselect: true,
multiboxonly: true,
beforeSelectRow: function (rowid, e) {
var $target = $(e.target), $td = $target.closest("td"),
iCol = $.jgrid.getCellIndex($td[0]),
colModel = $(this).jqGrid("getGridParam", "colModel");
if (iCol >= 0 && $target.is(":checkbox")) {
return false;
}
return true;
},
onSelectRow: function (rowid, isSelected, event) {
var rowData = $("#list").jqGrid("getRowData", rowid);
var checkbox = jQuery(this).find('#' + rowid + ' input#jqg_list_'+rowid+'[type=checkbox]');
if ($(checkbox).is(':checked')) {
$(checkbox).attr('checked', false);
}
},
});
http://jsfiddle.net/yNw3C/12696/
如您所见,问题是当我点击之前选中的行时,它会取消选中复选框。
【问题讨论】:
-
不清楚您到底在寻找什么。你能发布一个 JsFiddle 到目前为止你所拥有的并描述它是如何不正确的吗?
-
我正在尝试获取行选择不会选中该行上的复选框的行为,并且选中复选框不会选中该行。我希望我是清楚的。
标签: javascript jquery jqgrid