delRowDataメソッドを使用すると、ローカル行を削除できます。
delGridRowは、必要に応じてフォームの編集から使用できます。私はhereと記述し、フォーマッタのために使用しました: 'actions'(here,here、もともとはhereを参照してください)。
var grid = $("#list"),
myDelOptions = {
// because I use "local" data I don't want to send the changes
// to the server so I use "processing:true" setting and delete
// the row manually in onclickSubmit
onclickSubmit: function(options, rowid) {
var grid_id = $.jgrid.jqID(grid[0].id),
grid_p = grid[0].p,
newPage = grid_p.page;
// reset the value of processing option which could be modified
options.processing = true;
// delete the row
grid.delRowData(rowid);
$.jgrid.hideModal("#delmod"+grid_id,
{gb:"#gbox_"+grid_id,
jqm:options.jqModal,onClose:options.onClose});
if (grid_p.lastpage > 1) {// on the multipage grid reload the grid
if (grid_p.reccount === 0 && newPage === grid_p.lastpage) {
// if after deliting there are no rows on the current page
// which is the last page of the grid
newPage--; // go to the previous page
}
// reload grid to make the row from the next page visable.
grid.trigger("reloadGrid", [{page:newPage}]);
}
return true;
},
processing:true
};
と、更新
grid.jqGrid('delGridRow', rowid, myDelOptions);
を使用:multiselect: true
myDelOptions
の場合には、次のように変更することができる:キーボードをサポートしました:
var grid = $("#list"),
myDelOptions = {
// because I use "local" data I don't want to send the changes
// to the server so I use "processing:true" setting and delete
// the row manually in onclickSubmit
onclickSubmit: function(options) {
var grid_id = $.jgrid.jqID(grid[0].id),
grid_p = grid[0].p,
newPage = grid_p.page,
rowids = grid_p.multiselect? grid_p.selarrrow: [grid_p.selrow];
// reset the value of processing option which could be modified
options.processing = true;
// delete the row
$.each(rowids,function(){
grid.delRowData(this);
});
$.jgrid.hideModal("#delmod"+grid_id,
{gb:"#gbox_"+grid_id,
jqm:options.jqModal,onClose:options.onClose});
if (grid_p.lastpage > 1) {// on the multipage grid reload the grid
if (grid_p.reccount === 0 && newPage === grid_p.lastpage) {
// if after deliting there are no rows on the current page
// which is the last page of the grid
newPage--; // go to the previous page
}
// reload grid to make the row from the next page visable.
grid.trigger("reloadGrid", [{page:newPage}]);
}
return true;
},
processing:true
};
を更新し削除操作で「削除」ボタンをデフォルトに設定する追加することができますdelSettings
追加オプション
afterShowForm: function($form) {
var form = $form.parent()[0];
// Delete button: "#dData", Cancel button: "#eData"
$("#dData",form).attr("tabindex","1000");
$("#eData",form).attr("tabindex","1001");
setTimeout(function() {
$("#dData",form).focus(); // set the focus on "Delete" button
},50);
}
ありがとうございました。あなたの答えに基づいて質問を更新しました – Andrus
@Andrus:jqGridのナビゲータバーを使用する場合は、[navGrid](http://www.trirand.com/jqgridwiki/doku)の 'prmDel'パラメータとして' myDelOptions'を使うことができます.php?id = wiki:ナビゲータ#定義)。ローカルのフォーム編集を実装するコードを投稿し、[対応する提案]を投稿しました(http://www.trirand.com/blog/?page_id=393/bugs/small-bug-in-generating-new-id-in -postit-of-editgridrow /#p22393)をトリランドフォーラムに追加します。私はもっとはできない。次に、 'multiselect:true'の使い方について書いてきました。それは**絶対に新しい要件です**。 jqGridはグリッド編集でmustiselectを指向しません。 – Oleg
ありがとうございます。最初の質問に投稿されたオプションは 'multiselect:true'でした。 jQgrid標準削除ボタンは選択された行をすべて削除しますが、ローカル置換は1行だけ削除します。 – Andrus