質問: "editable:true" 列を正しく並べ替えるにはどうすればよいですか?
次のリンクは、編集可能な列をソートできるようにする「onclick」ハンドラー関数を提供しているようです。( https://stackoverflow.com/a/9290716/652078 )
しかし、それを使用していても、列をクリックすると次のエラーが表示されます。
'handler' is null or not an object
列をクリックしたときのメッセージ
以下に、上記のリンクから借用した列定義と「クリック」ハンドラー コードを示します。
-このソリューションに関して、機能を妨げる古いものはありますか?
-または、私の列定義は、そのような「onclick」ハンドラーが機能しないようにしますか?
助けてくれてありがとう!
列の定義は次のとおりです。
{
name: 'recType',
label: 'recType',
index: 'recType',
width: 100,
fixed: true,
keys: true,
editable: true,
edittype: "select",
editoptions: {value: rectypelist},
stype: 'select',
formatter: 'select'
},
クリックイベント関数(上記リンクで説明されている手法)...
$(".ui-jqgrid-htable th").click(function() //.on('click', 'th', function(e) //
{
var $grid = contentB1Grid;
$.each($grid[0].grid.headers, function () {
var $th = $(this.el), i, l, clickHandler, clickHandlers = [],
currentHandlers = $._data($th[0], "events"), //$th.data('events'),
clickBinding = currentHandlers.click;
if ($.isArray(clickBinding)) {
for (i = 0, l = clickBinding.length; i < l; i++) {
clickHandler = clickBinding[i].handler;
clickHandlers.push(clickHandler);
$th.unbind('click', clickHandler);
}
}
$th.click(function () {
var p = $grid[0].p, savedRow = p.savedRow, j, len = savedRow.length;
if (len > 0) {
// there are rows in cell editing or inline editing
if (p.cellEdit) {
// savedRow has the form {id:iRow, ic:iCol, name:nm, v:value}
// we can call restoreCell or saveCell
//$grid.jqGrid("restoreCell", savedRow[0].id, savedRow[0].ic);
$grid.jqGrid("saveCell", savedRow[0].id, savedRow[0].ic);
} else {
// inline editing
for (j = len - 1; j >= 0; j--) {
// call restoreRow or saveRow
//$grid.jqGrid("restoreRow", savedRow[j].id);
$grid.jqGrid("saveRow", savedRow[j].id);
}
}
}
});
l = clickHandlers.length;
if (l > 0) {
for (i = 0; i < l; i++) {
$th.bind('click', clickHandlers[i]);
}
}
});
});