【问题标题】:Grid is not loading as a item of penal.网格未作为惩罚项加载。
【发布时间】:2016-07-01 11:16:48
【问题描述】:

我正在尝试通过 ajax 调用将网格加载为项目面板。我的网格没有加载。你能帮我么。这是我正在尝试的,因为我没有在 ext ajax 调用中获得范围。

我的代码是

{
                xtype: 'panel',
                title: "Search Result",
                height:500,
                items: [
                        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) {
                                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) {
                                 //debugger;
                                   //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);     
                                var grid = new Ext.grid.GridPanel({
                                        store: this.store,
                                        flex: 1,
                                        columns: this.columns,
                                        stripeRows: true,
                                        id: 'RID',
                                        autoHeight: true,
                                        //sm: new Ext.grid.Checkbo;xSelectionModel({singleSelect:true}),
                                        frame: true,
                                    }); 
                            }
                        })
                        ]

            }]

实际上我没有得到范围,所以我放在这里。

【问题讨论】:

    标签: ajax extjs extjs3


    【解决方案1】:
    {
        xtype: 'panel',
        title: "Search Result",
        height:500,
        items: [{
            xtype : 'GridPanel',
            store: new Ext.data.ArrayStore({
                fields : this.fields
            }),
            flex: 1,
            columns: this.columns,
            stripeRows: true,
            id: 'RID',
            autoHeight: true,
            //sm: new Ext.grid.Checkbo;xSelectionModel({singleSelect:true}),
            frame: true,
            listeners {
                afterRenderer : function(){
                    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) {
                            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) {
                                //debugger;
                                //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);
                        }); 
                    }
                })
            }
        }
        ]
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-12-25
      • 2021-04-01
      • 2014-12-01
      • 2011-08-17
      • 2021-09-27
      • 2019-07-10
      • 1970-01-01
      • 2014-04-30
      相关资源
      最近更新 更多