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调试了一下,可以看到从后台返回的数据,如下图所示 问题补充:谢谢楼上的回答,刚试过了,不行我网上找了些资料,有人说是布局的问题,我的grid嵌套在tab里,tabpanel嵌套在viewport里,没有去刷新,所以显示不了数据,但我不知道怎么修改

解决方案

<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gbk"> <title>04.form</title> <link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" /> <script type="text/javascript" src="../../adapter/ext/ext-base.js"></script> <script type="text/javascript" src="../../ext-all.js"></script> <script type="text/javascript">Ext.onReady(function(){CurrentDataGrid = function(viewer, config){ this.viewer = viewer; Ext.apply(this, config); this.store = new Ext.data.Store({ 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 }); }; var s = {"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":"办公照明用电"}]}; Ext.extend(CurrentDataGrid, Ext.grid.GridPanel,{renderTo:Ext.getBody(),height:500}); new CurrentDataGrid().store.loadData(s);}); </script> </head> <body> </body></html>你的程序这样测试 发现没有问题 都出来了
解决方案二:
没有刷新 只有取得grid然后 grid.store.load后台
解决方案三:
fields: [ {name:'ammeterid', mapping: 'ammeterid'}, {name:'ammeterno', mapping:'ammeterno'}, {name:'measureno', mapping:'measureno'},{name:'ammindex', mapping:'ammindex'}, {name:'termno', mapping:'termno'}, {name:'equip', mapping:'equip'}, {name:'elcplace', mapping:'elcplace'}, {name:'elctype', mapping:'elctype'} ]
解决方案四:
fields: ["ammeterid", "ammeterno", "measureno", "ammindex", "termno", "equip", "elcplace", "elctype"] 改成fields: [{name:'ammeterid', mapping: 'ammeterid'}, {name:'ammeterno', mapping:'ammeterno'},{name:'measureno', mapping:'measureno'}{name:'ammindex', mapping:'ammindex'}{name:'termno', mapping:'termno'}{name:'equip', mapping:'equip'},{name:'elcplace', mapping:'elcplace'},{name:'elctype', mapping:'elctype'}]试试

时间: 2024-10-15 20:26:23

ext grid 数据加载成功,却显示不了数据的相关文章

visual studio 2010 连接数据库时测试连接成功但是显示无法添加数据连接未能加载文件和程序集

问题描述 visualstudio2010连接数据库时测试连接成功但是显示无法添加数据连接未能加载文件和程序集 解决方案 解决方案二:断句有点困难,爱莫能助

javascript-diiv点击时间数据加载中显示加载中图片加载完还原

问题描述 diiv点击时间数据加载中显示加载中图片加载完还原 <div class="lead-more" id="lead-more" style="margin-top: 120px;"><a href="javascript:;">查看更多>></a></div> $(document).ready(function(){ $("#lead-more&

android scrollview-重写的ListView onMeasure()方法,数据加载多了最后一行总是显示不全

问题描述 重写的ListView onMeasure()方法,数据加载多了最后一行总是显示不全 ScrollView嵌套ListView重写的ListView onMeasure()方法,数据加载多了最后一行总是显示不全,这个有人遇到过嘛 解决方案 没有这个问题,显示不全是因为你的onMeasure没有对吧 int expandSpec = MeasureSpec.makeMeasureSpec( Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); su

C#使用Jquery zTree实现树状结构显示 异步数据加载_C#教程

C#使用Jquery zTree实现树状结构显示_异步数据加载 JQuery-Ztree下载地址:https://github.com/zTree/zTree_v3 JQuery-Ztree数结构演示页面:  http://www.treejs.cn/v3/demo.php 关于zTree的详细解释请看演示页面,还有zTree帮助Demo.  下面简要讲解下本人用到的其中一个实例(直接上关键代码了): 异步加载节点数据:  A-前台: <link href="zTree_v3-master

使用加载图片解决在Ajax数据加载中页面出现短暂空白的问题(推荐)_AJAX相关

在项目中用ajax异步获取数据后有时会因为数据问题或者网络问题,页面一直显示空白,现在用加载图片来过渡这种状态: <script> $(function(){ $.ajax({ url:'',//提供接口的文件地址链接 dataType:'json', type:'POST', beforeSend: function(){ $('#loading').html("<img src=\"images/loading.gif\" width=\"15

Silverlight DataGrid使用WCF RIA Service实现Load-on-demand的数据加载

在Windows或者ASP.NET Web应用程序中,我们经常可以看到在Grid控件上通过Load-on-demand的方式来提高系统性能,提升用户体验. 所谓Load-on-demand就是在最初表格数据加载时只加载当前表格中用户可以看到的行数,当用户向下滚动或拖拽纵向滚动条时,再将需要显示的数据通过某种方式动态加载进来. 那么对于Silverlight,我们可以使用DataGrid通过WCF RIA Service来实现这个功能. 1.      WCF RIA Service 我们将会使用

&amp;#106avascript使图片加载进度实时显示

加载|显示 javascript使图片加载进度实时显示 function chk(){  l--;  document.getElementById("aa").innerText=""+((sum-l)*100/sum)+"%"  if (l==0){     for (var i=0;i<sum;i++)       document.body.innerHTML+="<img src='"+imgs[i].s

SWF关于远程源和允许跨域数据加载

加载|数据 与 HTML 页面类似,SWF 文件是用于捕获和显示信息的窗口.然而,SWF 文件可以在浏览器中保持加载状态,同时用新信息持续更新而不必重新加载整个页面.使用动作脚本函数和方法,可以向服务器端脚本.文本文件以及 XML 文件发送信息,也可从它们那里接收信息. 此外,服务器端脚本可从数据库中请求特定信息,然后将其转发给 SWF 文件.可用多种不同的语言撰写服务器端脚本:其中最常用的是 CFML.Perl.ASP (Microsoft Active Server Pages) 和 PHP

nhibernate数据加载之Criteria加载

加载|数据 Criteria是通过一组条件表达式(Expression)来加载数据的,它返回满足条件的对象集合. 主要接口为ICriteria,实现为CriteriaImpl类,此类加有Internal修饰,因此不能在程序集外显示创建,nhibernate在session对象中为我们提供了一个方法CreateCriteria,此方法返回ICriteria接口. 这里列出了ICriteria接口的一些方法:SetMaxResults:设置返回的最大结果数,可用于分页:SetFirstResult: