在网格问题中从xml文件加载动态数据
Loading dynamic data from xml file in grid Issu
我正在尝试使用"Ext.ux.touch "在父视图中集成表视图。电网"图书馆。但是我无法在表中显示数据。我的代码如下:
网格视图: Ext.define('RasovaiApp.view.Grid', {
extend : 'RasovaiApp.Ext.ux.touch.grid.List',
xtype : 'grid-grid',
id: 'grids',
requires : [
'RasovaiApp.Ext.ux.touch.grid.feature.Feature',
'RasovaiApp.Ext.ux.touch.grid.feature.Editable',
'RasovaiApp.Ext.ux.touch.grid.feature.Sorter',
'Ext.field.Number',
'RasovaiApp.store.CalFieldsStore'
],
store: ['RasovaiApp.store.CalFieldsStore'],
config : {
title : 'Grid',
store : true,
columns : [
{
header : 'Country',
dataIndex : 'country',
width : '10%',
height : 20,
editor : {
xtype : 'textfield'
}
},
{
header : 'Month',
dataIndex : 'month',
width : '15%',
height : 20,
editor : {
xtype : 'textfield'
}
},
{
header : 'Location',
dataIndex : 'location',
width : '20%',
height : 20,
editor : {
xtype : 'textfield'
}
},
{
header : 'Date',
dataIndex : 'date',
width : '10%',
height : 20,
editor : {
xtype : 'textfield'
}
},
{
header : 'Teacher',
dataIndex : 'teacher',
width : '15%',
height : 20,
editor : {
xtype : 'textfield'
}
},
{
header : 'Contact',
dataIndex : 'contact',
width : '15%',
height : 20,
editor : {
xtype : 'textfield'
}
}
],
features : [
{
ftype : 'RasovaiApp.Ext.ux.touch.grid.feature.Sorter',
launchFn : 'initialize'
},
{
ftype : 'RasovaiApp.Ext.ux.touch.grid.feature.Editable',
launchFn : 'initialize'
}
]
},
applyStore : function() {
return new RasovaiApp.store.CalFieldsStore();
}
});
存储类:
Ext.define('RasovaiApp.store.CalFieldsStore',{
extend: 'Ext.data.Store',
xtype: 'stores',
requires : [
'RasovaiApp.model.Calendarfields'
],
config : {
autoLoad: true,
model : 'RasovaiApp.model.Calendarfields',
grouper : {
groupFn : function (record) {
return record.get('calendar');
}
}
}
});
模型类:
Ext.define('RasovaiApp.model.Calendarfields', {
extend : 'Ext.data.Model',
config : {
fields : [
'country',
'location',
'month',
'date',
'teacher',
'contact'
],
proxy : {
type : 'ajax',
url: 'http://127.0.0.1/calfield1.xml',
reader : {
type : 'xml',
rootProperty : 'calendars',
record : 'calendar'
}
}
}
});
我可以显示表的标题,但当我从xml文件中获取数据时,它不显示表中的数据,但当我尝试显示静态数据时,它显示在表中。
谢谢
我弄清楚了问题所在。问题是,我将存储设置为Grid视图而没有获得回调数据,因此数据在设置为视图时不存在。"Grid.js"中的以下更改将起作用:
Ext.define('RasovaiApp.view.Grid', {
extend : 'RasovaiApp.Ext.ux.touch.grid.List',
xtype : 'grid-grid',
id: 'grids',
requires : [
'RasovaiApp.Ext.ux.touch.grid.feature.Feature',
'RasovaiApp.Ext.ux.touch.grid.feature.Editable',
'RasovaiApp.Ext.ux.touch.grid.feature.Sorter',
'Ext.field.Number',
'RasovaiApp.store.CalFieldsStore'
],
config : {
title : 'Grid',
store : true,
store : Ext.create('RasovaiApp.store.CalFieldsStore'),
columns : [
{
header : 'Country',
dataIndex : 'country',
width : '10%',
height : 20,
editor : {
xtype : 'textfield'
}
},
{
header : 'Month',
dataIndex : 'month',
width : '15%',
height : 20,
editor : {
xtype : 'textfield'
}
},
{
header : 'Location',
dataIndex : 'location',
width : '20%',
height : 20,
editor : {
xtype : 'textfield'
}
},
{
header : 'Date',
dataIndex : 'date',
width : '10%',
height : 20,
editor : {
xtype : 'textfield'
}
},
{
header : 'Teacher',
dataIndex : 'teacher',
width : '15%',
height : 20,
editor : {
xtype : 'textfield'
}
},
{
header : 'Contact',
dataIndex : 'contact',
width : '15%',
height : 20,
editor : {
xtype : 'textfield'
}
}
],
features : [
{
ftype : 'RasovaiApp.Ext.ux.touch.grid.feature.Sorter',
launchFn : 'initialize'
},
{
ftype : 'RasovaiApp.Ext.ux.touch.grid.feature.Editable',
launchFn : 'initialize'
}
]
}});
相关文章:
- 有没有任何方法可以将控制器从文件加载到ui路由器$stateProvider中
- Ajax文件加载和<输入>文件加载
- 使用Bootstrap将JSON文件加载到表中
- 将组合JSON文件加载到谷歌地图
- 将文本文件加载到javascript中
- jQuery Mobile样式从另一个文件加载内容
- 使用JavaScript将压缩文本文件加载到字符串中
- 数组在手动写入时有效,但从文本文件加载时无效
- 如何在打印前等待javascript文件加载twitter,并在打印后关闭选项卡
- 从文本文件加载jsondata时出现空白页
- AngularJS:如何使用ng-include将javascript文件加载到部分中
- 使用jquery将html文件加载到html中,用于离线/本地项目
- 从另一个grunt文件加载grunt任务
- 将php文件加载到弹出窗口中,并将php变量发布到该弹出窗口中(使用onclick)
- 如何使用node.js将不同的json文件加载到不同的json对象中
- 将变量从服务器上的外部文件加载到 HTML 文档中
- 节点 - 将 JSON 文件加载到代码中
- 如何使用 JavaScript/jQuery 将 XML 文件加载到 JSP/HTML 页面
- NodeJS和ExpressJS-Javascript文件加载,但CSS文件不加载;t
- D3.js:通过Force Layout从JSON文件加载多个网络