2012-02-14 20 views
0

私は、列のインライン編集を可能にするグリッドパネルを持っています。このコラムはエディターとしてコンボボックスを使用し、 "change"イベントと "select"イベントのどちらも、編集された値をバックトレースして、変更された行をグリッドパネルから取得することができません。ExtJSのGridPanelからモデルを取得

私はextがそうので、私は、グリッドに戻るには

combo.up() 

のような単純な何かを行うことができないエディタのコンボボックスを浮くと信じています。ここで

は、ビューからグリッドパネルである:ここで

{ 
    xtype: 'gridpanel', 
    title: 'Important Projects', 
    id: 'importantProjectsGrid', 
    dockedItems: [], 
    flex: 1, 
    columns: [ 
     { header: 'Quote Name', dataIndex: 'QuoteName', flex: 4 }, 
     { header: 'Quote Status', dataIndex: 'QuoteStatusID', flex: 6, editor: { 
      xtype: 'combobox', 
      editable: false, 
      action: 'QuoteStatus', 
      selectOnTab: true, 
      store: 'statuses', 
      queryMode: 'local', 
      displayField: 'Description', 
      valueField: 'Description' 
     } } 
    ], 
    store: 'myimpprojects', 
    selModel: { 
     selType: 'cellmodel' 
    }, 
    plugins: [Ext.create('Ext.grid.plugin.CellEditing', { 
     clicksToEdit: 1 
    })] 
} 

は、これに関連するコントローラのコードです:任意の助け

init: function() { 
    this.control({ 
     '[action=QuoteStatus]': { 
      change: function (combo, new_value, old_value, opts) { 
       // I need to go back up from this combobox 
       // to get the row that this value was edited in 
       // to grab an ID value from that row's data 
       // in order to make an ajax request 
      } 
     } 
    }); 
}, 

ありがとう!

答えて

1

CellEditingプラグインにリスナーを配置してみてください。グリッド、レコード、フィールド、行と列のインデックスへの参照を含むオブジェクトを受け取るbeforeeditedit、およびvalidateeditのイベントがあります。あなたは、イベントハンドラのコンボボックスをチェックしてそこからあなたの情報を処理できるはずです。

ドキュメントのページへのクイックリンク:Ext.grid.plugin.CellEditing

+0

お返事ありがとうございます、これは私が探しているもののラインに沿っています – thinkdevcode

2

ストアのupdateイベントを監視できます。

init: function() { 
    this.getMyimpprojectsStore().on('update', function(store, record) { 
     // do something with record 
    }); 
    // ... 
}, 
1

私は更新プラグインが根底にある店舗のAPIを介して、自動的に更新を処理し、真のオートシンクなどのプロキシ場合は、サーバーに自動的にデータをポストすることを確信しています。

設定されたプロキシの例:

Ext.define('MyApp.store.YourStore', { 
extend: 'Ext.data.Store', 

model: 'MyApp.model.YourGridModel', 
autoSync: true, //Commits the changes realtime to the server 
proxy: { 
    type: 'ajax', 
    batchActions : true, //Commits the changes everytime a value is changed if true o otherwise store the changes and batch update them in 1 single post 
    api: { 
     read: 'path/to/select', 
     create: 'path/to/create', 
     update: 'path/to/update', 
     destroy: 'path/to/delete' 
    }, 
    reader: { 
     type: 'json', 
     root: 'results', 
     successProperty: 'success' 
    }, 
    writer: { 
     type: 'json', 
     writeAllFields: true 
    }, 
    listeners: { 
     exception: function(proxy, response, operation){ 

      Ext.MessageBox.show({ 
       title: 'REMOTE EXCEPTION', 
       msg: operation.getError(), 
       icon: Ext.MessageBox.ERROR, 
       buttons: Ext.Msg.OK 
      }); 
     } 
    } 
}, 
listeners: { 
    write: function(proxy, operation){ 

     var response = Ext.JSON.decode(operation.response.responseText); 

     if(response.success == true) 
     {   
      //TODO: Proxy - Messageboxes might be a little anoying we might instead use the status bar in teh grid or something so show status of the operation 
      Ext.MessageBox.show({ 
       title: this.xFileLibraryTitle, 
       msg: response.message, 
       icon: (response.success == true)? Ext.MessageBox.INFO : Ext.MessageBox.ERROR, 
       buttons: Ext.Msg.OK 
      }); 
     } 
    } 
} 

})。

私は2つのconfigsのために特別になります。「オートシンク」と「batchActions」

・ホープこれはあなたの問題をさらにあなたを助けます!

+0

は答えてくれてありがとう、私はデータを削除/更新するためにプロキシを使用してはいけません。私は手動でajaxリクエストを使用します。 – thinkdevcode

+0

私はあなたがプロキシを使用してより多くの価値を得ると思うが、それは問題ありません...しかし、あなたはすべてのステップを完全にコントロールしたいいくつかの特別なシナリオを実行している可能性があります。乾杯! –

関連する問題