你好,
我是extjs5和mvvm的新手。我想发出一个ajax请求,以便显示一个树面板,其中包含用php捕获的数据。
这是我的商店
Ext.define('MyApp.store.servicesStore', {
extend: 'Ext.data.TreeStore',
// alias: 'store.servicesStore',
storeId : 'servicesStore',
model : 'MyApp.model.servicesModel',
proxy: {
type: 'ajax',
url: 'app/store/data/GetServices.php'
},
root: {
text: 'Events',
id: 'root'
},
autoLoad: true,
folderSort: true
});
我已经看到"成功"可以解决这个问题,但我不需要成功,因为它只显示在树面板中
Ext.define('MyApp.view.tabServices.servicesTab', {
extend: 'Ext.tree.Panel',
xtype: 'servicesTab',
layout: {
type: 'border'
},
useArrows: true,
rootVisible: false,
store: {type: 'servicesStore'},
forceFit: true,
columns: [{
xtype: 'treecolumn',
dataIndex: 'text',
width: 600
}, {
dataIndex: 'mbt',
cls: 'mbtcss',
width: 80
}, {
dataIndex: 'bt',
cls: 'btcss',
width: 75
}, {
dataIndex: 'details', // port separated from rest
width: 60
}, {
dataIndex: 'code',
width: 80
}]
});
所以,当我启动我的应用程序时,会出现"您正试图解码一个无效的JSON字符串",我该如何让它理解我实际上使用的是php文件?更准确地说,该代码在extjs 3.4 中工作
要运行在ExtJS 4下运行的PHP代码,您必须修改PHP以返回JSON格式的数据。或者,您将"启用兼容性"设置为版本4。
请参阅下的"启用兼容性"http://docs.sencha.com/extjs/5.0/whats_new/5.0/extjs_upgrade_guide.html#Enabling_Compatibility.
compatibility: {
ext: '4.2'
}