宁宁和静静 2010-08-05 14:41
浏览 518
已采纳

ext grid 数据加载成功,却显示不了数据

我的grid从后台加载数据成功,却显示不了数据 !

整体布局是一个viewport,左侧树形,右侧表格,当我单击树形的值时,在表格显示结果。

这是grid 代码:
CurrentDataGrid = function(viewer, config){
this.viewer = viewer;
Ext.apply(this, config);

this.store = new Ext.data.Store({
    proxy: new Ext.data.HttpProxy({
        url: '../currentData/currentData_gridData.jspx'
    }),
    reader: new Ext.data.JsonReader({
        root: 'values',
        totalProperty: 'rows',
        remoteSort: true,
        fields: ["ammeterid", "ammeterno", "measureno", "ammindex", "termno", "equip", "elcplace", "elctype"]
    })
});
this.store.setDefaultSort('ammeterno', "DESC");


this.check_select = new Ext.grid.CheckboxSelectionModel({
    handleMouseDown: Ext.emptyFn
});
this.columns = [new Ext.grid.RowNumberer(), this.check_select, {
    id: 'ammeterid',
    header: "测量点ID",
    dataIndex: 'ammeterid',
    width: 50,
    hidden: true
}, {
    id: 'ammeterno',
    header: "通讯地址",
    dataIndex: 'ammeterno',
    sortable: true,
    width: 100
}, {
    id: 'measureno',
    header: "测量点号",
    dataIndex: 'measureno',
    sortable: true,
    width: 80
}, {
    id: 'ammindex',
    header: "表序号",
    dataIndex: 'ammindex',
    sortable: true,
    width: 50
}, {
    id: 'termno',
    header: "所属终端",
    dataIndex: 'termno',
    sortable: true,
    width: 100
}, {
    id: 'equip',
    header: "关联设备",
    dataIndex: 'equip',
    sortable: true,
    width: 100
}, {
    id: 'elcplace',
    header: "用电场所",
    dataIndex: 'elcplace',
    sortable: true,
    width: 100
}, {
    id: 'elctype',
    header: "用电类型",
    dataIndex: 'elctype',
    sortable: true,
    width: 100
}];
CurrentDataGrid.superclass.constructor.call(this, {
    region: 'center',
    id: 'CurrentDataGridID',
    sm: this.check_select
});

};
Ext.extend(CurrentDataGrid, Ext.grid.GridPanel, {
loadData: function(treeNodeID, selectType){
this.store.baseParams = {
treeValue_ID: treeNodeID,
selectType: selectType
};
this.store.load({
callback: function(r, options, success){
alert(r.length);
if (success) {
alert(r.length);
}
else {
alert("异常!");
}
}
});

}

});

后台返回数据:

{"rows":4,"values": [{"ammeterid":10,"ammeterno":"002084000075","measureno":112,"ammindex":12,"termno":"99999999","equip":"b- 12(一楼厂房)","elcplace":"照明用电场所","elctype":"办公照明用电"}, {"ammeterid":12,"ammeterno":"002084000066","measureno":114,"ammindex":14,"termno":"99999999","equip":"b- 14(四楼照明区)","elcplace":"照明用电场所","elctype":"办公照明用电"}, {"ammeterid":13,"ammeterno":"002084000067","measureno":115,"ammindex":15,"termno":"99999999","equip":"b- 15(三楼照明区)","elcplace":"照明用电场所","elctype":"办公照明用电"}, {"ammeterid":14,"ammeterno":"002084000069","measureno":116,"ammindex":16,"termno":"99999999","equip":"b- 16(五楼照明区)","elcplace":"照明用电场所","elctype":"办公照明用电"}]}

在IE和FF里都不显示数据,也不报错!用firebug调试了一下,可以看到从后台返回的数据,如下图所示

[img]http://dl.iteye.com/upload/attachment/288630/01887e97-8d5a-3f65-b16c-ee3117bcd3ec.jpg[/img]

  • 写回答

4条回答 默认 最新

  • works001 2010-08-05 15:14
    关注




    04.form



    <br> Ext.onReady(function(){<br> CurrentDataGrid = function(viewer, config){ <br> this.viewer = viewer; <br> Ext.apply(this, config); </p> <pre><code>this.store = new Ext.data.Store({ reader: new Ext.data.JsonReader({ root: &#39;values&#39;, totalProperty: &#39;rows&#39;, remoteSort: true, fields: [&quot;ammeterid&quot;, &quot;ammeterno&quot;, &quot;measureno&quot;, &quot;ammindex&quot;, &quot;termno&quot;, &quot;equip&quot;, &quot;elcplace&quot;, &quot;elctype&quot;] }) }); this.store.setDefaultSort(&#39;ammeterno&#39;, &quot;DESC&quot;); this.check_select = new Ext.grid.CheckboxSelectionModel({ handleMouseDown: Ext.emptyFn }); this.columns = [new Ext.grid.RowNumberer(), this.check_select, { id: &#39;ammeterid&#39;, header: &quot;测量点ID&quot;, dataIndex: &#39;ammeterid&#39;, width: 50, hidden: true }, { id: &#39;ammeterno&#39;, header: &quot;通讯地址&quot;, dataIndex: &#39;ammeterno&#39;, sortable: true, width: 100 }, { id: &#39;measureno&#39;, header: &quot;测量点号&quot;, dataIndex: &#39;measureno&#39;, sortable: true, width: 80 }, { id: &#39;ammindex&#39;, header: &quot;表序号&quot;, dataIndex: &#39;ammindex&#39;, sortable: true, width: 50 }, { id: &#39;termno&#39;, header: &quot;所属终端&quot;, dataIndex: &#39;termno&#39;, sortable: true, width: 100 }, { id: &#39;equip&#39;, header: &quot;关联设备&quot;, dataIndex: &#39;equip&#39;, sortable: true, width: 100 }, { id: &#39;elcplace&#39;, header: &quot;用电场所&quot;, dataIndex: &#39;elcplace&#39;, sortable: true, width: 100 }, { id: &#39;elctype&#39;, header: &quot;用电类型&quot;, dataIndex: &#39;elctype&#39;, sortable: true, width: 100 }]; CurrentDataGrid.superclass.constructor.call(this, { region: &#39;center&#39;, id: &#39;CurrentDataGridID&#39;, sm: this.check_select }); </code></pre> <p>}; </p> <p>var s = {&quot;rows&quot;:4,&quot;values&quot;: [{&quot;ammeterid&quot;:10,&quot;ammeterno&quot;:&quot;002084000075&quot;,&quot;measureno&quot;:112,&quot;ammindex&quot;:12,&quot;termno&quot;:&quot;99999999&quot;,&quot;equip&quot;:&quot;b- 12(一楼厂房)&quot;,&quot;elcplace&quot;:&quot;照明用电场所&quot;,&quot;elctype&quot;:&quot;办公照明用电&quot;}, {&quot;ammeterid&quot;:12,&quot;ammeterno&quot;:&quot;002084000066&quot;,&quot;measureno&quot;:114,&quot;ammindex&quot;:14,&quot;termno&quot;:&quot;99999999&quot;,&quot;equip&quot;:&quot;b- 14(四楼照明区)&quot;,&quot;elcplace&quot;:&quot;照明用电场所&quot;,&quot;elctype&quot;:&quot;办公照明用电&quot;}, {&quot;ammeterid&quot;:13,&quot;ammeterno&quot;:&quot;002084000067&quot;,&quot;measureno&quot;:115,&quot;ammindex&quot;:15,&quot;termno&quot;:&quot;99999999&quot;,&quot;equip&quot;:&quot;b- 15(三楼照明区)&quot;,&quot;elcplace&quot;:&quot;照明用电场所&quot;,&quot;elctype&quot;:&quot;办公照明用电&quot;}, {&quot;ammeterid&quot;:14,&quot;ammeterno&quot;:&quot;002084000069&quot;,&quot;measureno&quot;:116,&quot;ammindex&quot;:16,&quot;termno&quot;:&quot;99999999&quot;,&quot;equip&quot;:&quot;b- 16(五楼照明区)&quot;,&quot;elcplace&quot;:&quot;照明用电场所&quot;,&quot;elctype&quot;:&quot;办公照明用电&quot;}]}; <br> Ext.extend(CurrentDataGrid, Ext.grid.GridPanel,{<br> renderTo:Ext.getBody(),<br> height:500<br> }); </p> <p>new CurrentDataGrid().store.loadData(s);</p> <p>});<br>




    你的程序这样测试 发现没有问题 都出来了
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的