是否有一種方式來獲得與此類似一個開關按鈕http://www.ok-soft-gmbh.com/jqGrid/SimpleLocalGridWidthRadioButton2.htm 與選擇/取消選擇所有包含複選框的複選框的行爲。 行選擇和複選框在該行可以不鏈接,就像在與單選按鈕的例子。如何在點擊jqgrid中的行時取消選中複選框?
UPDATE:
這裏是我的代碼片段:
$("#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到目前爲止,並描述它是如何不正確的? –
我試圖讓那裏行選擇不會在該行檢查複選框的行爲,並在檢查複選框,將不會選擇該行。 我希望我很清楚。 – Renton