DataStore
(ExtJS 4)が付いているGridPanel
があります。ユーザーが行を選択して削除ボタンをクリックすると、選択したレコードのIDを使用してPOST
リクエストをサーバーに送信し、レコードを削除してからデータストアを再ロードします。データストアを読み込むときにUncaught例外が発生するのはなぜですか?
レコードが正常に削除された場合、サーバーはOK
というステータスコードを返します。ユーザーがGridPanel
のLAST ROWを選択した場合でも、私は次のエラーを取得する:
Uncaught TypeError: Cannot read property 'id' of undefined
私はGrid Panel
またはDataStore
には他のイベントを持っていません。ここで
は私の削除コードです:私は間違っ
function deleteTEDetailExceptions() {
try {
if(tedetailExceptionsEditorGrid.getSelectionModel().selected.length < 1) {
statusMessage("Please select an exception first", true);
return;
}
var record = tedetailExceptionsEditorGrid.getSelectionModel().selected.items[0];
currentTEDetailExceptionKey = record.data["tedetailExceptionKey"];
// send the delete request
Ext.Ajax.request({
url: '/timesheets/action.do',
method: 'POST',
params:{
tedetailExceptionKey : currentTEDetailExceptionKey,
type : "tedetailExceptions",
"delete" : "true"
},
success: function(response) {
if(response.statusText == "OK") {
tedetailExceptionsEditorGrid.getSelectionModel().clearSelections();
TEDetailExceptionsStore.remove(record);
// reload the store
Ext.Function.defer((function(){
TEDetailExceptionsStore.load({
params:{
timeEntryDetailKey : timeEntryDetailKey,
type : "tedetailExceptions"
}
});
}),250);
}
}
});
}
catch(e) {
console.log(e);
}
}
何をしているのですか?私は次のコードで問題を解決するために管理
EDIT
。私が必要としなかったときにデータストアをリロードするのはかなり愚かでした!
function deleteTEDetailExceptions() {
try {
if(tedetailExceptionsEditorGrid.getSelectionModel().selected.length < 1) {
statusMessage("Please select an exception first", true);
return;
}
var record = tedetailExceptionsEditorGrid.getSelectionModel().selected.items[0];
tedetailExceptionsEditorGrid.getView().refresh();
currentTEDetailExceptionKey = record.data["tedetailExceptionKey"];
// send the delete request
Ext.Ajax.request({
url: '/timesheets/action.do',
method: 'POST',
params:{
tedetailExceptionKey : currentTEDetailExceptionKey,
type : "tedetailExceptions",
"delete" : "true"
},
success: function(response) {
if(response.statusText == "OK") {
TEDetailExceptionsStore.remove(record);
}
}
});
}
catch(e) {
// console.log(e);
}
}
これはうまくいきました。ありがとう!私がExtJSについてもっと学ぶにつれて、データストアのリロードが削除のためにばかげていることが分かりました。再度、感謝します。 – cbmeeks