2012-01-15 2 views
1

디자이너를 사용 중입니다. 내 목표는 newBtn을 클릭하여 지금까지 시작된 상점 레코드를 업데이트하는 것입니다. 나는 그것을 호출 한 함수 밖에서 처리하려고 시도하고있다.저장 데이터를 변경할 때 extjs 업데이트

버튼을 클릭하면 작동합니다.

이 ./application.js

Ext.Loader.setConfig({ 
    enabled: true 
}); 

Ext.application({ 
    name: 'MyApp', 

    stores: [ 
     'MyArrayStore' 
    ], 

    launch: function() { 
     Ext.QuickTips.init(); 

     var cmp1 = Ext.create('MyApp.view.TradeGrid', { 
      renderTo: Ext.getBody() 
     }); 

    cmp1.show(); 


    //PROBLEM HERE 
    // This actually does something but when maxIndex is printed to the console it = 0 
    // Meaning that no data has been loaded to grid 
    // Am I wrong thinking it should? As the other file loads two data cells right away 

     cmp1.addRecord([]); 

    //PROBLEM HERE 

./TradeGrid.js

Ext.define('MyApp.view.TradeGrid', { 
    extend: 'MyApp.view.ui.TradeGrid', 

    initComponent: function() { 
     var me = this; 


     me.callParent(arguments); 

     var button = me.down('button[text=newBtn]'); 
     button.on('click', me.onSubmitBtnClick, me); 

    }, 

    addRecord: function(myRecordArray) { 

      var grid = Ext.getCmp("TradeGrid"); //defined by -> Property: id 
      var store = grid.getStore(); 

      var maxIndex = store.getCount(); 
      console.log(maxIndex);    //maxIndex PRINT to CONSOLE 


      var res = store.insert(maxIndex, [["ll", "kk", "00"]]); 


      console.log(this); 

    }, 

    onSubmitBtnClick: function() { 
     this.addRecord([]); 
    } 




}); 

     } 
    }); 

처음 두 데이터는 내가 볼

[ 
["Ace Supplies", "Emma Knauer", "555-3529"], 
["Best Goods", "Joseph Kahn", "555-8797"], 

] 

답변

1

당신이 내선을 사용하여 그리드 참조를 얻을 그리드에로드 .getCmp - 구성 요소의 ID를 하드 코드했음을 의미합니다. 정말 좋은 생각은 아니므로 itemId를 사용하는 것이 좋습니다. 그것은 톰에게 이상한 버그를 인도 할 수 있습니다. 어쩌면 당신이 할 수없는 것이 작동하지 않을 수도 있습니다. id를 itemId로 변경하십시오.

+0

디자이너가 생성 한 코드를 망쳐 버리는 결과를 낳았습니다. 실제로는 웹 소켓을 사용할 준비가되지 않았지만 지금 코드를 작성하는 방식으로 응답이 작동합니다. – BAR

관련 문제