私はExtJs3.3.1でライブグリッドを使用していますが、この質問はExtJsにとってグローバルであると信じています。ストアのリスナーは、イベントがどのグリッドから発生したかをどのように知るのですか?
ここに理由といくつかのコードがあります。
ストアにリスナーがあり、更新時にグリッドで選択された行を知り、イベントを一時停止したいと思います。これはすべて、グリッドで選択を行い、その範囲のフィールドを更新し、選択全体でそのフィールドを更新できるようにするためです。行を強調表示するだけで、チェックボックスなしで選択が行われます。このリスナーは多くのグリッドで使用されているため、gridlistenerがパラメーターとして取得するものから取得する方法が必要ですが、それは保存、記録、およびアクションのみです。
Ext.override(Ext.ux.grid.livegrid.Store, {
listeners: {
'update': function(store, record, action) {
if (action=='commit'){ //each update has 2 actions, an edit and a commit
var selected = grid.getSelectionModel().getSelections(); //need to know which grid
if (selected.length>1){ //if more than one row selected
grid.suspendEvents();
store.writer.autoSave = false;
for(var i=0; i < selected.length; i++){
if (this.fieldChanged) {
for (var name in this.fieldChanged) {
//get the field changed and update the selection with the value
if (selected[i].get(name)!=this.fieldChanged[name]){
selected[i].set(name, this.fieldChanged[name]);
}
}
}
}
grid.resumeEvents();
store.fireEvent("datachanged", store);
store.writer.autoSave = true;
}
}
if (action=='edit'){
this.fieldChanged = record.getChanges()
}
}
}
});