php 如何使用ligerui
1个回答
推荐于2016-10-07 · 知道合伙人软件行家
关注
展开全部
ligerui主要是用来写前台UI的,而php主要是用来做后台数据的,以下是一个调用其表格插件的示例:
<?php
include '../../common/view/header.html.php';
include '../../common/view/ligerui.html.php';
?>
<script type="text/javascript">
$(function ()
{
$("#maingrid").ligerGrid({
columns: [
{ display: '排序', name: 'id', width: 100},
{ display: '名字', name: 'keytask', width: 100 }], width: 600,
//data: jsonObj,
dataAction: 'server',
url:"index.php?m=ktm&f=get&",
pageSizeOptions: [1,2,5,10]
});
});
</script>
</head>
<body>
<div id="maingrid"></div>
<div style="display:none;">
</div>
<?php include '../../common/view/footer.html.php';?>
控制代码:
<?php
class ktm extends control{
public function index(){
$this->display();
}
public function get(){
$page = $this->post->page;
$pageSize = $this->post->pagesize;
$ktms = $this->ktm->get($pageSize,$page);
echo $ktms;
}
}?>
模型代码:
<?php
class ktmModel extends Model{
public function get($pageSize,$page){
$page = $page;
$start = $pageSize*$page - $pageSize;
$limit = $start.",".$pageSize;
$ktms = $this->dao->select('*')->from(TABLE_KTM)->limit($limit)->fetchALL();
$count= $this->dao->select('count(*) as count')->from(TABLE_KTM)->fetchALL();
foreach ($count as $datanum){
$num = $datanum->count;
}
$ktms = '{"Rows":'.json_encode($ktms).", Total:".$num.",page :".$page.", start :".$start.",pageSize: ".$pageSize."}";
return $ktms;
}
}
?>
<?php
include '../../common/view/header.html.php';
include '../../common/view/ligerui.html.php';
?>
<script type="text/javascript">
$(function ()
{
$("#maingrid").ligerGrid({
columns: [
{ display: '排序', name: 'id', width: 100},
{ display: '名字', name: 'keytask', width: 100 }], width: 600,
//data: jsonObj,
dataAction: 'server',
url:"index.php?m=ktm&f=get&",
pageSizeOptions: [1,2,5,10]
});
});
</script>
</head>
<body>
<div id="maingrid"></div>
<div style="display:none;">
</div>
<?php include '../../common/view/footer.html.php';?>
控制代码:
<?php
class ktm extends control{
public function index(){
$this->display();
}
public function get(){
$page = $this->post->page;
$pageSize = $this->post->pagesize;
$ktms = $this->ktm->get($pageSize,$page);
echo $ktms;
}
}?>
模型代码:
<?php
class ktmModel extends Model{
public function get($pageSize,$page){
$page = $page;
$start = $pageSize*$page - $pageSize;
$limit = $start.",".$pageSize;
$ktms = $this->dao->select('*')->from(TABLE_KTM)->limit($limit)->fetchALL();
$count= $this->dao->select('count(*) as count')->from(TABLE_KTM)->fetchALL();
foreach ($count as $datanum){
$num = $datanum->count;
}
$ktms = '{"Rows":'.json_encode($ktms).", Total:".$num.",page :".$page.", start :".$start.",pageSize: ".$pageSize."}";
return $ktms;
}
}
?>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |