2016-06-29 1 views
0

그리드를 생성했는데 xml에서 그리드 데이터와 컬럼을로드하려고합니다. 내 컬럼은 헤더 태그와로드 중입니다.하지만 G 태그에서 오는 데이터가로드되지 않습니다. 코드 : 그리드그리드 데이터가 xml에서로드되지 않습니다

initComponent: function() { 
    this.fields = []; 
    this.columns = []; 
    this.data = []; 
    Ext.Ajax.request({ 
         url: 'XML/hart.xml', 
         scope: this, 
         timeout: global_constants.TIMEOUT, 
         method: "GET", 
         disableCaching: true, 
         failure: function(response) { 
          utils.showOKErrorMsg(sdisMsg.ajaxRequestFailed); 
         }, 
         success: function(response) { 
          debugger; 
          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.fieldLength = this.fields.length; 
           this.record = []; 
           for (i = 0; i < this.fieldLength; i++) { 
            this.record.push(columnData); 
           }     
           this.data.push(this.record); 
          }, this); 
           this.store = new Ext.data.ArrayStore({ 
            fields : this.fields 
           }); 
           this.store.loadData(this.data); 
         } 
        }); 
    buildField: function(header) { 
    this.fields.push({ 
     name: header.getAttribute("DATAINDEX") 
    }); 
    buildColumn: function(header) { 
    var hiddenflg = !(header.getAttribute("VISIBLE")); 
    if (header.getAttribute("VISIBLE") == "false") 
     hiddenflg = true; 
    var strHeaderName = ''; 
    if ((Ext.isIE && !PC.common.isIE10())) 
     strHeaderName = header.text; 
    else 
     strHeaderName = header.textContent; 
    var strToolTip = ""; 
    this.columns.push({ 
     header: Ext.util.Format.htmlEncode(strHeaderName), 
     tooltip: strToolTip, 
     dataIndex: header.getAttribute("DATAINDEX"), 
     width: parseInt(header.getAttribute("LENGTH")), 
     metaID: header.getAttribute("M"), 
     enableHdMenu: false, 
     hidden: hiddenflg, 
     menuDisabled: true, 
     sortable: false, 
     scope: this, 
     /*renderer : function (value, metaData, record, rowIndex, colIndex, store){ 
      debugger; 

     },*/ 
     fixed: false, 
     expanded: true 
    }); 
}, 
} 

코드 : 그리드에서 나는 상점과 열을주고있다.

{xtype: 'panel', 
       title: "Search Result", 
       height:500, 
       items: [{ 
        xtype: 'grid', 
        id: 'COHART_GRID', 
        autoHeight: true, 
        selType: 'checkboxmodel', 
        frame: true, 
        store: this.store, 
        autoHeight: true, 
        stripeRows: true, 
        columns: this.columns, 
        bbar: [{ 
         xtype: 'button', 
         text: 'Exclude', 
         handler: function() { 
          debugger; 
         } 
        }, { 
         xtype: 'button', 
         text: 'Include', 
         handler: function() { 
          //debugger; 
         } 
        }] 
       }] 

      } 

내 XML을 필요로하는 경우를 게시 할 예정입니다. 도와 주셔서 감사합니다.

+0

내 XML은 "

<= "HEADERS 그룹 셋>"입니다 연구 ID :
연구 제목
< HEADER VISIBLE = "true"를 LENGTH = "100"ISSORTABLE = "true"를 DATATYPE = "문자열"DATAINDEX = "STT"ISKEY = "true"를 DOMAIN = ""> 연구 약물 David

+0

문제를 나타내는 [fiddle] (http://fiddle.sencha.com)을 작성하십시오. " STU : " " 을" SUB : – Alexander

답변

1

buildField 함수에서 getAttribute를 올바르게 사용하여 속성에 액세스 할 수 있지만 this.record.push(columnData);에서는 부족합니다. 내가 생각

this.record = []; 
for (i = 0; i < this.fieldLength; i++) { 
    var fieldName = this.fields[i].name 
    this.record[fieldName] = columnData.getAttribute(fieldName); 
}     

테스트되지 않은 보증없이의 라인을 따라 뭔가를 원하지만 그것에 대해해야합니다.

+0

는 this.store이 내 데이터를 적용한 후 EXL 처럼오고있다 "" – David

+0

하지만 this.data는 올바른 값을 가지고있다. – David

+0

감사합니다. 나는 약간의 변경을했고 그것은 효과가있었습니다. – David

관련 문제