2016-07-01 4 views
1

초기화 컴포넌트에 Ajax를 작성했고 모든 데이터가 this.store에 필요합니다. 그러나 내가 정의한 그리드에서 저장소의 범위를 얻지는 않습니다. 저는 Ajax 성공의 대괄호를 닫고 있기 때문에 저는 아닙니다. 올바른 방법은 무엇입니까? 내 코드는 다음과 같습니다 동쪽 패널에서 같은 초기화 구성 요소에서그리드에 저장 범위를 얻는 방법

initComponent: function() { 
    this.fields = []; 
    this.columns = []; 
    this.data = []; 
    this.store = []; 
    Ext.Ajax.request({ 
         url: 'XML/1Cohart.xml', 
         scope: this, 
         timeout: global_constants.TIMEOUT, 
         method: "GET", 
         disableCaching: true, 
         failure: function(response) { 
          utils.showOKErrorMsg(sdisMsg.ajaxRequestFailed); 
         }, 
         success: function(response) { 
          var datas = response.responseXML; 
          Ext.each(datas.getElementsByTagName("HEADER"), function(header) { 
           this.buildField(header); 
           this.buildColumn(header); 
          }, this); 
          Ext.each(datas.getElementsByTagName("G"), function (columnData) { 
           this.buildData(columnData); 
           this.fieldLength = this.fields.length; 
           this.record = []; 
           for (i = 0; i < this.fieldLength; i++) { 
            //debugger; 
            var fieldName = this.fields[i].name 
            this.record[i] = columnData.getAttribute(fieldName); 
           } 
           this.data.push(this.record);     
          }, this); 
          this.store = new Ext.data.ArrayStore({ 
           fields : this.fields 
          }); 
          this.store.loadData(this.data); // Getting correct data in this.store 
         }, 
        }); 

내가 그리드를 정의했다. 어떤 칼럼이 왔는지는 모르겠지만 상점은 얻지 못하고있다.

그리드 코드는

  { 
      xtype: 'panel', 
      region: "east", 
      header: true, 
      collapsible: true, 
      autoScroll: true, 
      //columnWidth: 0.5, 
      width: "30%", 
      hideBorders: true, 
      split: true, 
      items: [{ 
       xtype: 'panel', 
       title: "Search Result", 
       height:500, 
       items: [{ 
        xtype: 'grid', 
        itemid: 'ABC_GRID', 
        store : this.store, 
        autoHeight: true, 
        sm: new Ext.grid.CheckboxSelectionModel({singleSelect:true}), 
        frame: true, 
        columns : this.columns, 
       }] 

      }]   
+0

'initComponent'가 어떤 구성 요소에서 호출됩니까? 귀하의 그리드 코드가 정의 된 곳은 어디입니까? –

+0

그리드도 init 구성 요소에 있습니다. Ajax 성공에서만'this.store'의 범위를 잃어 가고 있습니다. – David

답변

0

의 저장 그리드를 얻고 다시 this.store에 데이터를로드 한 후입니다 ExtJS로 3

우리는 Ext.ComponentQuery.queryExt.getCmp()는 사용할 필요가 들어

Ext.ComponentQuery.query("#ABC_GRID")[0].reconfigure(this.store); 

지원되지 않습니다. 그리드의 id 속성을 id:ABC_GRID으로 정의해야합니다.

Ext.getCmp("ABC_GRID").reconfigure(this.store) 
+0

그래서 그리드를 선언하면 상점에 비워 두어야합니까? – David

+0

미안하지만 시도는했지만 작동하지 않습니다. 디버거에서도 멈추지 않습니다. – David

+0

Ext.ComponentQuery.query는 EXTJS 3에서 사용할 수 없습니다. – David

-1

은 오히려 당신이 grid.getview().으로 getStore()를 호출 할 수 있습니다 This.store 호출하는 대신, 당신은 당신이 데이터를로드 할 그리드의 가게를 얻을 것이다.

관련 문제