2019独角兽企业重金招聘Python工程师标准>>>

<jQuery EasyUI最新版下载>

在本教程中,我们将向你展示如何从数据库中获取数据,并将其显示到数据网格中,然后演示如何根据用户输入的搜索关键字搜索显示结果。

查看演示

创建数据网格

创建具有分页功能的数据网格,然后将工具栏添加到其中。

< table id = "tt" class = "easyui-datagrid" style = "width:600px;height:250px" url = "datagrid24_getdata.php" toolbar = "#tb" title = "Load Data" iconcls = "icon-save" rownumbers = "true" pagination = "true" >
< thead >
< tr >
< th field = "itemid" width = "80" >Item ID</ th >
< th field = "productid" width = "80" >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 = "150" >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 = "#" class = "easyui-linkbutton" plain = "true" onclick = "doSearch()" >Search</ a >
</ div >

当用户输入搜索值并点击搜索按钮时,“doSearch”函数将会被调用:

function doSearch(){
$( '#tt' ).datagrid( 'load' ,{
itemid: $( '#itemid' ).val(),
productid: $( '#productid' ).val()
});
}

上面的代码调用了“load”方法来加载新的数据网格(datagrid)数据。我们需要传递“itemid”和“productid”参数到服务器。

include  'conn.php' ;
$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;
$result = array();
$where =  "itemid like '$itemid%' and productid like '$productid%'" ;
$rs = mysql_query( "select count(*) from item where " . $where);
$row = mysql_fetch_row($rs);
$result[ "total" ] = $row[0];
$rs = mysql_query( "select * from item where " . $where .  " limit $offset,$rows" );
$items = array();
while ($row = mysql_fetch_object($rs)){
array_push($items, $row);
}
$result[ "rows" ] = $items;
echo json_encode($result);

下载该EasyUI示例:easyui-datagrid-demo.zip

有兴趣的朋友可以点击查看更多有关jQuery EasyUI的文章!

转载于:https://my.oschina.net/u/2317468/blog/545970

jQuery EasyUI使用教程之在数据网格中添加搜索功能相关推荐

  1. jQuery EasyUI使用教程之创建展开行详细编辑表单的CRUD应用

    2019独角兽企业重金招聘Python工程师标准>>> 当切换datagrid视图到"detailview"时,用户可以展开一行来显示该行下面的任何详细信息.此功 ...

  2. jQuery EasyUI使用教程之使用标记创建树形菜单

    2019独角兽企业重金招聘Python工程师标准>>> jQuery EasyUI最新试用版下载请猛戳>> 一个树形菜单可以使用标记创建.easyui树形菜单也可以定义在 ...

  3. JQuery Easyui/TopJUI 用JS创建数据表格并实现增删改查功能

    JQuery Easyui/TopJUI 用JS创建数据表格并实现增删改查功能 JQuery Easyui/TopJUI 用JS创建数据表格并实现增删改查功能 html <table id=&q ...

  4. easyui select ajax,easyui的combobox根据后台数据实现自动输入提示功能

    easyui的combobox根据后台数据实现自动输入提示功能 发布时间:2020-06-11 10:09:41 来源:51CTO 阅读:1981 作者:crackernet adauhuehkek最 ...

  5. hazelcast配置内存_在内存数据网格中引入hazelcast imdg

    hazelcast配置内存 Today's article will be oriented to a very specific concept, which is the In-Memory Da ...

  6. layui自定义查询条件html页面,Layui的数据表格+springmvc实现搜索功能的例子_飛雲_前端开发者...

    如下所示: 主要在前端页面加: 搜索ID: userid content 搜索 在 reload:function () { var keyWord=$("#keyWord").v ...

  7. 历史数据导出excel_在数据产品中对导出功能的思考

    本篇文章:3993字 预计阅读:11分钟 前段时间,产品内上线了一个新的统计模块,出于上线时间的考虑,第一期没有提供"导出"功能,上线后不久就有用户向我反馈需求,产生了如下对话 用 ...

  8. python解决数据框中添加一行或者一列(DataFrame的行列处理)

    1.解决数据框中添加一行(给定值) ###原数据框data_Peak_2 = pd.DataFrame({"Peak_density": np.ndarray.tolist(hma ...

  9. mysql删除表中的一列数据_在数据表中添加或删除一列

    注意: 我们希望能够尽快以你的语言为你提供最新的帮助内容. 本页面是自动翻译的,可能包含语法错误或不准确之处. 我们的目的是使此内容能对你有所帮助. 可以在本页面底部告诉我们此信息是否对你有帮助吗? ...

最新文章

  1. k-means算法的理解与实现
  2. MobaXterm无法退格删除,出现^H
  3. python six库_six库 解决python2的项目如何能够完全迁移到python3
  4. Linux小细节-1
  5. 在一个tomcat 里面 两个相同的项目不能同时运行??
  6. 免费Linux系统和生信宝典原创学习教程
  7. 中国小伙CVPR 18论文遭质疑:同行难复现,要求评议组撤稿
  8. mac sublime text 3 列操作,替换相同内容, 用动态输入的方式
  9. 关于SoUI界面库处理从WM_LBUTTONUP到按钮事件的消息路由过程分析
  10. 【Matlab绘图】plot3函数绘制三维点或线图
  11. 解决 Github用户名 变为 invalid-email-address 问题
  12. 自考2018版《管理经济学》第一章导论——思维导图
  13. @RunWith注解作用
  14. 仿照vue实现双向数据绑定兼容IE6
  15. gnuplot(九)、gnuplot画矢量与颜色设置
  16. day 19 C# 窗体金额换算
  17. Linux桌面 失败,ubuntu无法进入桌面,安装ubuntu-desktop失败的解决办法
  18. 2015年:跑步计划
  19. 方舟进官方服务器弹网页,进方舟服务器就弹白框
  20. int * arr 与 int arr[] 这两种定义数组方式的疑问

热门文章

  1. HTTPRunner学习笔记
  2. 【4】测试用例设计-判定表法
  3. linux环境配置sonarqube
  4. 金三银四 | 吃透这套题,面试更有底气
  5. 现网问题排查实战:Jstat,Jstack,Jmap
  6. PAT甲级1058(进制转换的“/” ,“%”干货!)
  7. PDE10 wave equation: d'Alembert's formula
  8. PDE2 three fundamental examples
  9. MATLAB中的光照处理
  10. 高斯牛顿法 matlab代码实现