jqGrid を使い始めたばかりで、カスタムの削除ボタンを使用して行を削除したいと考えています。以下のコード スニペットを使用しています。
try {
var cellValue;
var id;
jQuery("#editDataGridList").jqGrid({
datatype: "local",
width: 900,
height: 270,
colNames: ['Action', 'Interview id', 'Date of observation', 'Name of enumerator'],
onSelectRow: function (id) {
debugger;
var rowData = jQuery(this).getRowData(id);
cellValue = rowData['InterviewId'];
},
colModel: [
{
name: 'actions', index: 'InterviewId', sortable: false,
formatter: function (rowId, cellval, colpos, rwdat, _act) {
return "<input type='button' id='btnid' value='delete' class='btn' onClick='deleteRecords(" + cellValue + ");' />";
}
},
{ name: 'InterviewId', index: 'InterviewId' },
{ name: 'Date', index: 'Date' },
{ name: 'NameOfEnum', index: 'NameOfEnum' }
],
multiselect: false,
caption: "Edit already entered data"
});
}
catch (e) {
alert(e.message);
}
上記のコードは、この関数呼び出しを使用して、削除のために選択された行の値を渡します
function deleteRecords(rowData) {
alert(rowData);
}
残念ながら、rowData 値は未定義です。同じ構造を使用して行を削除するにはどうすればよいですか?