Extjs6问题——grid不显示数据
来源:互联网 发布:福建知鱼科技有限公司 编辑:程序博客网 时间:2024/04/30 20:17
使用MVVC框架显示一个表格,遇到gridPanel只显示表头,但是不显示数据的问题,可以从以下的几个角度考虑。
1. 数据是否有问题?检查返回的json数据结构是否与reader对应。
2. models里面fields对应关系是否正确?保险起见最好加上mapping。
3. 比较诡异的一个问题是define view的时候,store如果是引用的方式,即:store:’{xxx}‘,store并不会在view 被创建的时候创建一个实例,这里强制在store的时候用store:Ext.create('xxx.xx.xxx');才正确的加载了数据。
下面记录下更正之后的代码:
View:
Ext.define('Admin.view.dashboard.MalfunctionListInbox',{ extend: 'Ext.grid.GridPanel', xtype: 'malfunctionlistinbox', alias: 'widget.malfunctionlistinbox', requires: [ 'Ext.grid.GridPanel', 'Ext.grid.View', 'Ext.selection.CheckboxModel', 'Admin.view.dashboard.MalfunctionListInboxController', 'Admin.view.dashboard.MalfunctionListModel', 'Admin.store.dashboard.MalfunctionListStore' ], cls: 'email-inbox-panel shadow-panel', viewModel:{ type: 'malfunctionlist' }, store:Ext.create('Admin.store.dashboard.MalfunctionListStore'), controller: 'malfunctionlistcontroller', ViewConfig:{ preserveScrollOnRefresh: true, preserveScrollOnReload: true, }, selModel: { selType: 'checkboxmodel', checkOnly: true, showHeaderCheckbox: true }, listeners: { 'cellclick': 'onGridCellItemClick' }, layout:{ type : 'fit', }, headerBorders: false, rowLines: false, autoRender:true, columns:[ { xtype:'gridcolumn', dataIndex:'id', text:'id', hidden:true }, { xtype:'gridcolumn', dataIndex: 'date', text:'日期', width:90, renderer:Ext.util.Format.dateRenderer('Y年m月d日 H:i') }, { xtype:'gridcolumn', dataIndex:'unit_name', text:'单位名称' }, { xtype:'gridcolumn', dataIndex:'malfunction_name', text:'故障名称' }, { xtype:'gridcolumn', dataIndex:'malfunction_type', text:'故障线路类型' }, { xtype:'gridcolumn', dataIndex:'malfunction_nature', text:'故障性质' }, { xtype:'gridcolumn', dataIndex:'malfunction_reason', text:'故障原因' } ]});
ViewModel:
Ext.define('Admin.view.dashboard.MalfunctionListModel',{extend:'Ext.app.ViewModel', requires:['Admin.store.dashboard.MalfunctionListStore','Admin.model.dashboard.MalfunctionListModel'],alias:'viewmodel.malfunctionlist',stores:{ MalfunctionList: { xtype: 'MalfunctionListStore' }}});
Store:
Ext.define("Admin.store.dashboard.MalfunctionListStore",{ extend: 'Ext.data.Store', alias:'store.MalfunctionListStore', requires:[ 'Admin.model.dashboard.MalfunctionListModel', 'Ext.window.MessageBox' ], id: 'malfunctionlist', model:'Admin.model.dashboard.MalfunctionListModel', //pageSize:20, autoLoad:true, proxy:{ type:'ajax', url: '/app/data/dashboard/MalfunctionList.json', reader: { type:'json', rootProperty:'data', successProperty:'success', actionMethods:{ read: 'GET' } } }});
Model:
Ext.define("Admin.model.dashboard.MalfunctionListModel",{extend: 'Admin.model.Base', idProperty: 'id',field:[ { type: 'int', name: 'id', mapping:'id' }, { type:'date', name:'date', dateFormat:'Y-m-dTH:i', mapping: 'date' }, { type:'string', name:'unit_name', mapping: 'unit_name' }, { type:'string', name:'malfunction_name', mapping:'malfunction_name' }, { type:'string', name:'malfunction_type', mapping:'malfunction_type' }, { type:'string', name:'malfunction_nature', mapping:'malfunction_nature' }, { type:'string', name:'malfunction_reason', mapping:'malfunction_reason' }]});
0 0
- Extjs6问题——grid不显示数据
- Ext grid不显示数据问题解决
- FineUI Grid不显示数据解决方案
- 有关ext grid表头不显示问题
- Extjs Grid 只显示列名 不显示数据
- ext grid 显示数据精度丢失问题
- Extjs问题 -- grid只能显示一条数据
- [Extjs6]随记 store本地过滤数据显示
- extjs grid取到数据而不显示的解决
- LigerUI之Grid使用详解(一)——显示数据
- LigerUI之Grid使用详解(一)——显示数据
- LigerUI之Grid使用详解(一)——显示数据
- LigerUI之Grid使用详解(一)——显示数据
- LigerUI之Grid使用详解(一)——显示数据
- SourceGrid.Grid 数据显示
- extjs的grid只显示一行数据的问题
- dojo grid中无法显示数据的问题
- Extjs grid只能显示一条数据的问题
- 第五周项目3-时间类
- 【poj 1699】Best Sequence 题意&题解&代码(C++)
- cocos2d-js:调用scheduleUpdate()不执行update()方法的解决办法
- 使用OpenCV实现分水岭算法
- 有趣的有趣的家庭菜园
- Extjs6问题——grid不显示数据
- ReactNative学习十二-React-Native-Viewpager
- IOS设计模式-单例模式
- Android IntentService完全解析 当Service遇到Handler
- How to delete PACKAGE from HANA studio
- 经过static修饰过变量与不被static修饰的变量在运算中初始值的变化关系
- python学习2
- Windows 环境下Apache HTTP Server 2.2的安装和使用apache转发weblogic集群
- 冒泡排序