嗨請幫助我嘗試顯示一個以symfony 2爲後端的Extjs 4.2網格面板。如何在symfony控制器中編碼的extjs網格中顯示json數據
我config.yml
格:
pattern: /grid
defaults: { _controller:ExtAssExampleBundle:displaygrid:display}
requirements: { _format: (json), _method: GET }
我的控制器
類displaygridController延伸控制器
{
public function displayAction()
{
$repository = $em->getRepository('ExtAssexampdbBundle:movies');
$items = $repository->show();
$response = json_encode($items);
return $this->render('ExtAssExampleBundle:Default:grid.html.php',array('response'=>$response));
}
}
grid.html.php
Ext.onReady(函數()
{ Ext.define( '電影',{
extend: 'Ext.data.Model',
fields: [
{name:'id', type: 'int'},
{name:'title',type: 'string'},
{name:'director',type: 'string'},
{name:'released',type: 'string'},
{name:'genre', type: 'int'},
{name:'tagline',type:'string'}
] });
var mystore = Ext.create('Ext.data.JsonStore',
{
model: 'movie',
autoSync: true,
autoLoad: true,
data:response,
proxy: {
type:'ajax',
url:' ',
//我需要越過這裏是
reader: {
type:'json',
root: 'movies'
},
writer:{
encode: true,
writeAllFields: true,
type: 'json',
root: 'data'
}
},
});//store completed
var grid = Ext.create('Ext.grid.Panel',
{
style: 'margin-top: 1%; margin-left: 24%',
store: mystore,
id:'grid',
width: 700,
height: 300,
title: 'Movie Details',
collapsible: true,
closable:true,
maximizable: true,
frame:true,
dirty:false,
draggable: true,
stripedRows: true,
columns:
[
{header: 'MovieName', width: 100, sortable: true, dataIndex:response[0].title,editor:{xtype: 'textfield',allowBlank:false} },
{header: 'Director Name', width: 100, sortable: true, dataIndex: 'director',editor: 'textfield',allowBlank:false},
{header: 'Released Date', width: 150, sortable: true, dataIndex: 'released',editor: 'datefield',renderer: Ext.util.Format.dateRenderer('Y-m-d')},
{header:'Genre',width:150,sortable:true,dataIndex:'genre',editor:'numbe rfield」,},{ 標題: '標語',寬度:200,排序:真,dataIndex: '標語',編輯: '文本字段'},
],
});
mystore.load();
grid.render('table')
});
問題是我如何可以訪問哪些已被Symfony2的控制器與此
請在你的問題修復代碼:)你設置控制器的任何特定原因 - 使用不同的url進行兩次路由 - 一旦使用註釋,一次使用yml配置? – nifr
請檢查它現在nifr我已經編輯我的代碼 – Choco
我想這些annotion因爲無論我可以通過這些註釋值在ExtJS的的URL給出,但它dooesnot工作,所以我刪除它,請與本 – Choco