Thinkphp+Ext 怎么获取action的内容。谢谢
1、问题描述
直接访问模板的话能显示出来,但通过action的方式访问就不行,如:/myThink/index.php/Furm/furmList
请教高手为什么呢?
在action加上$this->display(); 也不行。
2、action 代码
class FurmAction extends Action{
public function furmList(){
$this->assign('title','列表');
$furm = M('Furm');
$start = ($_REQUEST["start"] == null)? 0 : $_REQUEST["start"];
$count = ($_REQUEST["limit"] == null)? 30 : $_REQUEST["limit"];
$where ='select * from t_furm where fname like "%'.$_REQUEST['keyWord'].'%" LIMIT '.$start.','.$count;
$rs = $furm->query($where);
$total=$furm->count();
$data = array();
while($row = @mysql_fetch_array($rs)){
$row['fname']=$where;//$row['fname'];
$row['id']=$row['id'];
array_push($data,$row);
}
echo '{"total":"'.$total.'","data":'.json_encode($rs).'}';
}
}
3、模板部分关键代码
Ext.onReady(function(){
Ext.QuickTips.init();
Ext.define('ForumThread', {
extend: 'Ext.data.Model',
fields: [
'id','fname'
],
idProperty: 'id'
});
// create the Data Store
var store = Ext.create('Ext.data.Store', {
pageSize: 4,
model: 'ForumThread',
remoteSort: true,
proxy: {
// load using script tags for cross domain, if the data in on the same domain as
// this page, an HttpProxy would be better
type: 'ajax',
url: '/myThink/index.php/Furm/furmList',
reader: {
root: 'data',
totalProperty: 'total'
},
simpleSortMode: true
// sends single sort as multi parameter
//simpleSortMode: true
},
sorters: [{
property: 'id',
direction: 'DESC'
}]
});
store.load({
params : {
limit : 4,
start : 0
}
});
/**/
var grid = Ext.create('Ext.grid.Panel', {
title:'管理员管理',
collapsible:true,
stripeRows: true,
store :store,
tbar: [
{
xtype:'label',
text:'请输入关键词:'
},{
xtype:'textfield',
id:'KeyWord',
store: store
},{
text:'搜索',
handler:function(){
keyWord = Ext.getCmp("KeyWord").getValue();
//window.location.href='/myThink/index.php/Furm/furmList?keyWord='+keyWord;
store.proxy.url='/myThink/index.php/Furm/furmList?keyWord='+keyWord;
// window.location.href='/myThink/Tpl/Furm/furmList.html';
}
}
],
viewConfig:{
forceFit: true,//当行大小变化时始终填充满
emptyText:'<div style="text-align:center; padding:20px">暂无数据</div>',
deferEmptyText:false,
stripeRows: true
},
columns: [
//Ext.create('Ext.grid.RowNumberer'),
{
text: 'ID',
sortable: true,
dataIndex: 'id',
width: 60
},{
text: '登录名',
sortable: true,
dataIndex: 'fname',
flex : 1
},
{
text: '添加时间',
sortable: true,
dataIndex: 'add_time',
flex : 1
},
{
text: '角色',
sortable: true,
dataIndex: 'group_name',
flex : 1
},
{
text: '权限管理',
sortable: true,
dataIndex: 'role_crtol',
flex : 1
},{
text: '操作',
sortable: true,
dataIndex: 'crtol',
flex : 1
}],
stripeRows: true,
renderTo:Ext.getBody(),
height:document.documentElement.clientHeight,
width:document.documentElement.clientWidth,
frame:true,
bbar: Ext.create('Ext.PagingToolbar', {
pageSize: 4,
store: store,
displayInfo: true,
plugins: Ext.create('Ext.ux.ProgressBarPager', {})
})
});
//delete user
});