2012-02-14 2 views
0

열의 인라인 편집을 허용하는 격자 패널이 있습니다. 이 열은 편집기로 콤보 상자를 사용하며 "change"이벤트 나 "select"이벤트도 편집 된 값을 백 트레이스하여 그리드 패널에서 변경된 행을 가져올 수없는 어떤 것을 제공합니다. ExtJS의 GridPanel에서 모델 얻기

나는 내선 내가 그리드로 돌아

combo.up() 

같은 간단한 일을 할 수 없도록 때문에 에디터의 콤보 상자를 수레 생각합니다. 어떤 도움

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 
      } 
     } 
    }); 
}, 

감사 :

여기
{ 
    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 
    })] 
} 

이에 관한 컨트롤러 코드 :

다음은 뷰에서 그리드 패널입니다!

답변

1

Listener를 CellEditing 플러그인에 삽입 해보십시오. 눈금, 레코드, 필드, 행 및 열 인덱스 등에 대한 참조를 포함하는 개체를 수신하는 beforeedit, editvalidateedit에 대한 이벤트가 있습니다. 이벤트 처리기에서 콤보 박스를 확인하고 거기에서 정보를 처리 할 수 ​​있어야합니다. 다큐먼트 페이지

빠른 링크 :

+0

답장을 보내 주셔서 감사합니다. 이것은 찾고있는 라인을 따라 있습니다. – thinkdevcode

2

상점의 update 이벤트를 모니터링 할 수 있습니다.

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

나는 업데이트 플러그인이 기본 상점의 API를 통해 자동으로 업데이트를 처리하고 서버에 자동으로 데이터를 게시 할 예정입니다 확신 해요 true로 자동 동기화로 프록시. 구성된 프록시

예 :

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 
      }); 
     } 
    } 
} 

});

나는 두 CONFIGS을 위해 특별히 보일 것이다 : "자동 동기화"와 "batchActions"

희망이 당신의 문제를 추가로 도움을!

+0

Ext.grid.plugin.CellEditing 대답 해 주셔서 감사합니다,하지만 난/삭제 데이터를 업데이트하기 위해 프록시를 사용하지 말아. 나는 수동으로 ajax 요청을 사용한다. 다시 고마워 다시 – thinkdevcode

+0

비록 괜찮아요,하지만 당신이 프록시를 사용하여 더 많은 가치를 얻을 것이라고 생각하지만 ... OFC U는 모든 단계를 완벽하게 제어하고자하는 몇 가지 특별한 시나리오를 실행 중일 수 있습니다, 그럼 괜찮아요! 건배! –