<?php
namespace app\index\controller;
use think\db;
use think\View;
class Index
{
public function index()
{
$view = new View();
return $view->fetch('index');
}
public function aa()
{
$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10;
$itemid = isset($_POST['itemid']) ? mysql_real_escape_string($_POST['itemid']) : '';
$productid = isset($_POST['productid']) ? mysql_real_escape_string($_POST['productid']) : '';
$offset = ($page-1)*$rows;
$map=array();
$result = array();
$map['itemid']=array('like','%'.$itemid.'%');
$map['productid']=array('like','%'.$productid.'%');
$mydb = db();
$rs = Db::name('test9')->where($map)->select();
$row = count($rs);
$result["total"] = $row;
$rs = Db::name('test9')->where($map)->limit($offset,$rows)->select();
$result["rows"] = $rs;
//return json_encode($result);
return json($result);
}
public function dd()
{
$view = new View();
return $this->$view->fetch('dd');
}
}index.html 模板<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="keywords" content="jquery,ui,easy,easyui,web">
<meta name="description" content="easyui help you build your web page easily!">
<title>Add search functionality in DataGrid - jQuery EasyUI Demo</title>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/easyui/themes/icon.css">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/easyui/demo/demo.css">
<script type="text/javascript" src="__PUBLIC__/easyui/jquery.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript">
function doSearch(){
$('#tt').datagrid('load',{
itemid: $('#itemid').val(),
productid: $('#productid').val()
});
}
</script>
</head>
<body>
<h2>Add search functionality in DataGrid</h2>
<div class="demo-info" style="margin-bottom:10px">
<div class="demo-tip icon-tip"> </div>
<div>Enter search values and press search button.</div>
</div>
<table id='tt' class="easyui-datagrid" style="width:700px;height:250px"
url="{:url('index/index/aa')}"
title="Searching" iconCls="icon-search" toolbar="#tb"
rownumbers="true" pagination="true">
<thead>
<tr>
<th field="itemid" width="80">Item ID</th>
<th field="productid" width="120">Product ID</th>
<th field="listprice" width="80" align="right">List Price</th>
<th field="unitcost" width="80" align="right">Unit Cost</th>
<th field="attr1" width="200">Attribute</th>
<th field="status" width="60" align="center">Stauts</th>
</tr>
</thead>
</table>
<div id="tb" style="padding:3px">
<span>Item ID:</span>
<input id="itemid" style="line-height:26px;border:1px solid #ccc">
<span>Product ID:</span>
<input id="productid" style="line-height:26px;border:1px solid #ccc">
<a href="javascript:void(0)" class="easyui-linkbutton" plain="true" onclick="doSearch()">Search</a>
</div>
</body>
</html>现在#itemid输入值,点击Search,easyui控件<table id='tt' class="easyui-datagrid" >并没有变化,而我想要用来做筛选。
ThinkPHP 是一个免费开源的,快速、简单的面向对象的 轻量级PHP开发框架 ,创立于2006年初,遵循Apache2开源协议发布,是为了敏捷WEB应用开发和简化企业应用开发而诞生的。ThinkPHP从诞生以来一直秉承简洁实用的设计原则,在保持出色的性能和至简的代码的同时,也注重易用性。并且拥有众多的原创功能和特性,在社区团队的积极参与下,在易用性、扩展性和性能方面不断优化和改进,已经成长为国内最领先和最具影响力的WEB应用开发框架,众多的典型案例确保可以稳定用于商业以及门户级的开发。