您可以設置一個click
事件處理程序的loadComplete
內:
loadComplete: function() {
var iCol = getColumnIndexByName ($(this), 'Aktiv'), rows = this.rows, i,
c = rows.length;
for (i = 1; i < c; i += 1) {
$(rows[i].cells[iCol]).click(function (e) {
var id = $(e.target).closest('tr')[0].id,
isChecked = $(e.target).is(':checked');
alert('clicked on the checkbox in the row with id=' + id +
'\nNow the checkbox is ' +
(isChecked? 'checked': 'not checked'));
});
}
}
其中
var getColumnIndexByName = function(grid, columnName) {
var cm = grid.jqGrid('getGridParam', 'colModel'), i, l;
for (i = 1, l = cm.length; i < l; i += 1) {
if (cm[i].name === columnName) {
return i; // return the index
}
}
return -1;
};
取而代之的alert
應該使用jQuery.ajax向服務器發送有關更新複選框狀態的信息。
您可以看到演示here。
完美的工作,現在我需要弄清楚如何發送動作進一步到我的控制器,它將發送到數據庫進一步。哦,我認爲我現在得到它 – Timsen
謝謝!謝謝! – jose
@ jose:不客氣! – Oleg