ExtJS6 store加载json不显示数据

qq_24480885 2018-01-03 08:14:35
现在的问题是在store中如果设置proxy为memory可以显示数据,但是使用ajax或jsonp,grid都无法显示数据,只显示表头

求解!!

GridPanel
Ext.define('Extjs6.view.online.OnlineGrid', {
extend : 'Ext.grid.Panel',
xtype : 'OnlineGrid',
alias : 'widget.OnlineGrid',

requires : ['Extjs6.store.online.Online'],

store : {
type : 'online'
},

border : false,
layout : 'fit',
selModel : {
selType : 'checkboxmodel',
checkOnly : true

},

columns : [{
xtype : 'actioncolumn',
width : 70,
align : 'center',
header : '操作',
name : 'actioncol',
items : [{
iconCls : 'x-fa fa-chain-broken',
tooltip : '踢出',
handler : function(grid, rowIndex,
colIndex, item) {

}
}]
}, {
text : '名称',
width : 150,
sortable : false,
dataIndex : 'UserName'
}, {
text : '登录时间',
width : 150,
sortable : false,
dataIndex : 'LoginTime',
renderer : Ext.util.Format.dateRenderer('Y-m-d H:i:s')
}, {
text : 'Ip',
width : 150,
sortable : false,
dataIndex : 'Ip'
}, {
text : 'SessionID',
width : 150,
sortable : false,
dataIndex : 'SessionID'
}, {
text : '最后访问地址',
flex : 1,
sortable : false,
dataIndex : 'LastUrl',
fixed : -1
}, {
text : '最后访问时间',
flex : 1,
sortable : false,
dataIndex : 'LastTime',
renderer : Ext.util.Format.dateRenderer('Y-m-d H:i:s')
}]
});

Store
Ext.define('Extjs6.store.online.Online', {
extend : 'Ext.data.Store',
alias : 'store.online',
model : 'Extjs6.model.Online',

requires : ['Extjs6.model.Online'],

data : {
data : [{
Id : "72be1ccf-e2a7-4906-bbe5-072cb17b0078",
UserID : "58a8660c-4ce8-4cae-8c31-ffb03a6c716b",
SessionID : "us5fzndnzslmjnnuogqvuapm",
UserName : "System",
Ip : "210.30.107.47",
LoginTime : "",
LastTime : "",
LastUrl : "",
Offline : "false"
}]
},

proxy : {
type : 'ajax',
url : 'online.json',
reader : {
type : 'json',
rootProperty : 'data'
// implicitIncludes : false
}
}
});

model
Ext.define('Extjs6.model.Online', {
extend: 'Ext.data.Model',
fields: [
{ name: 'Id', type: 'string' },
{ name: 'UserID', type: 'string' },
{ name: 'SessionID', type: 'string' },
{ name: 'UserName', type: 'string' },
{ name: 'LoginTime', type: 'string' },
{ name: 'LastTime', type: 'string' },
{ name: 'Ip', type: 'string' },
{ name: 'LastUrl', type: 'string' },
{ name: 'Offline', type: 'string' }
]
});


json内容
{
"success":true,
"data":[
{
"Id":"72be1ccf-e2a7-4906-bbe5-072cb17b0078",
"UserID":"58a8660c-4ce8-4cae-8c31-ffb03a6c716b",
"SessionID":"us5fzndnzslmjnnuogqvuapm",
"UserName":"System",
"Ip":"210.30.107.47",
"LoginTime":"",
"LastTime":"",
"LastUrl":"",
"Offline":"false"
},
{
"Id":"7fccfae2-2725-4d57-861f-07e138c84eb1",
"UserID":"d2bdce55-5b47-4567-8e57-d698eca939d1",
"SessionID":"wohd2oep2ximxveqc0nghfz2",
"UserName":"qywsc",
"Ip":"124.77.135.231",
"LoginTime":"",
"LastTime":"",
"LastUrl":"",
"Offline":"false"
}
]
}


json位置

...全文
799 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
业余草 2018-01-07
  • 打赏
  • 举报
回复
hookee 2018-01-07
  • 打赏
  • 举报
回复
直接访问ajax的url,看看返回的是不是正确的json格式
Go 旅城通票 2018-01-05
  • 打赏
  • 举报
回复
自己f12看发出的ajax请求地址url正确没有,是否200状态

Web开发学习资料推荐
extjs开发技巧
XDomainRequest,IE8+跨域请求对象

52,797

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ajax
社区管理员
  • Ajax
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧