Thinkphp+Ext 怎么获取action的内容。谢谢

bingyu709 2012-10-10 10:02:33
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

});

...全文
1334 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
bingyu709 2012-10-10
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]
既然你使用 Thinkphp,就得按 Thinkphp 的规矩来。不能自行其事

你需要先阅读手册中相关章节
5.17 判断请求类型
5.18 获取URL参数
5.19 AJAX返回
[/Quote]


谢谢高手,我看了一下,ajaxReturn()能返回值,客户端我是用这个方式提交的,但是不知道获取data数据时怎么写,谢谢。
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'

},


..........
..........
..........
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
},
..............
..............
xuzuning 2012-10-10
  • 打赏
  • 举报
回复
既然你使用 Thinkphp,就得按 Thinkphp 的规矩来。不能自行其事

你需要先阅读手册中相关章节
5.17 判断请求类型
5.18 获取URL参数
5.19 AJAX返回
xuzuning 2012-10-10
  • 打赏
  • 举报
回复
手册中有示例,为什么不看呢?

4,251

社区成员

发帖
与我相关
我的任务
社区描述
国内外优秀PHP框架讨论学习
社区管理员
  • Framework
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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