Cakephp 带Ext JS的Bancha基本版本-不在网格中显示数据
我正在为我的网站使用Bancha基本版本。我想使用ExtJS将emplyees表中的数据显示到网格中 以下是控制器的代码:Cakephp 带Ext JS的Bancha基本版本-不在网格中显示数据,cakephp,extjs,bancha,Cakephp,Extjs,Bancha,我正在为我的网站使用Bancha基本版本。我想使用ExtJS将emplyees表中的数据显示到网格中 以下是控制器的代码: class EmployeesController extends AppController { /** * @banchaRemotable */ public function getData(){ return $this->Employee->find('all'); } } 以下是我的
class EmployeesController extends AppController {
/**
* @banchaRemotable
*/
public function getData(){
return $this->Employee->find('all');
}
}
以下是我的JavaScript文件:
Ext.application({
name: 'BanchaExample',
launch: function() {
/**
* Example 1
* Create a grid panel which provides full CRUD support
*/
Bancha.getStub('Employee').index(function(result){
Ext.define('Employee', {
extend: 'Ext.data.Model',
fields: [ 'id', 'name' ]
});
var myStore = Ext.create('Ext.data.Store', {
model: 'Employee',
data: result.data
});
Ext.create('Ext.grid.Panel', {
renderTo: Ext.getBody(),
model: 'Employee',
width: 400,
height: 200,
title: 'Application Users',
//scaffold: 'MyApp.model.User'
columns: [
{
header: 'id',
width: 100,
ryinsortable: false,
hideable: false,
dataIndex: 'id'
},
{
header: 'name',
width: 150,
dataIndex: 'name'
}
]
});
});
}
});
它在我的控制台中给出以下响应:
[{“type”:“rpc”,“tid”:1,“action”:“Employee”,“method”:“read”,“result”:{“success”:true,“data”:[{“Employee”:{“id”:“1”,“name”:“test”},{“Employee”:{“id”:“2”,“name”:“tese”}],“message”:“预期响应是多个雇员记录,但一些记录缺少数据,因此没有将数据转换为Ext JS/Sencha Touch结构。”}]
仅显示带有标题的网格。数据不显示
请帮我解决这个问题。我不与班查合作,但这可能会有所帮助。 我看不到任何与商店的电网连接。还需要一些配置(读取器)来解析结果。”“数据”通常用于内联静态数据
Ext.define('Employee', {
extend : 'Ext.data.Model',
fields : [ {
name : 'id',
mapping : 'Employee.id'
}, {
name : 'name',
mapping : 'Employee.name'
} ]
});
var myStore = Ext.create('Ext.data.Store', {
model : 'Employee',
proxy : {
url : 'SPECIFY URL TO YOUR SERVICE',
type : 'ajax',
reader : {
type : 'json',
root : 'result.data'
}
}
});
also add store to grid and you can remove model in grid
Ext.create('Ext.grid.Panel', {
renderTo: Ext.getBody(),
store : myStore,
...
});
Bancha Basic不会自动将记录从CakePHP结构转换为Ext JS。想要做什么,你需要使用Bancha Pro 如果要使用Bancha Basic,则需要返回正确的Ext JS数据数组