EasyUI【DataGrid数据查询】

本文详细介绍了EasyUI的DataGrid组件,包括其基本属性如url、fitcolumns、rownumbers等,事件处理如onDblClickRow和按钮点击查询,以及分页设置和参数格式要求。此外,还涵盖了Dialog对话框窗口、Message消息窗口、Form表单的使用,以及从utils层到servlet层的数据查询实现。
摘要由CSDN通过智能技术生成

如需温习上一节内容,请点击下方链接进行跳转:EasyUI(Tree后端工作)_云彩123的博客-CSDN博客用户信息表(T_User)列名数据类型长度允许空默认值说明idvarchar36Nuuid()主键,ID号ushttps://blog.csdn.net/m0_64522859/article/details/124647333


目录

1.DataGrid

1.1 DataGrid基本属性

1.2 DataGrid事件

1.3 DataGrid分页

2.Dialog对话框窗口

3.Message消息窗口

4.Form表单

5、sql脚本代码:

6、DataGrid数据查询(utils层实现):

7、DataGrid数据查询(entity层实现):

8、DataGrid数据查询(Dao层实现):

9、DataGrid数据查询(Biz层实现):

10、DataGrid数据查询(servlet层实现):

11、DataGird数据查询(WEB层数据分页实现):

12、DataGird数据查询(WEB层模糊查询分页实现):


1.DataGrid

1.1 DataGrid基本属性

 1.1.1 基本属性

  •       url : '',         // 初始化请求路径
  •       fitcolumns : false,     // 列宽自适应
  •       singleSelect : true,     // 是否选中单行
  •       checkOnSelect : true,     // 点击行选中时该checkbox选中或取消选中
  •       rownumbers:true,            // 行号
  •       fit : true,         // 高宽自适应
  •       border : false,             // 是否显示边框
  •       title : '书本列表',     // datagrid标题
  •       striped : true,             // 显示斑马线效果

   1.1.2 toobar属性(增删改)
      toolbar : "#tb",            // 自定义工具栏

   1.1.3 formatter单元格格式化
    
   1.1.4 styler单元格样式

   1.1.5 sorter
   
   1.1.6 editor


1.2 DataGrid事件


   
   1.2.1 onDblClickRow双击行事件
   onDblClickRow:function(index,row){}

   1.2.2 按钮点击查询
   //查询参数
   var param={
    'bookName':$('#bookname').val(),
    'methodName':'query'
   };
   var options = $('#dg').datagrid('options');
   //指定请求Url地址
   options.url="bookAction.action";
   //开始加载数据
   $('#dg').datagrid('load', param); 

1.3 DataGrid分页

   1.3.1 属性设置
   pagination:true,    // 是否分页
   pageNumber:1,    // 初始化页码
   pageSize:10,        // 初始化每页显示条数

   1.3.2 请求/响应参数格式要求
   Request请求:{"page":页码,"rows":每页多少条记录}
   Response响应:{"total":总记录数,"rows":[{数据项1},{数据项2},{数据项3},...]}


2.Dialog对话框窗口

width : 400,
height : 292,
modal : true,
draggable : true,
collapsible : false,
minimizable : false,
maximizable : false,
title : '编辑书本信息',
buttons:"#dlg-buttons",
href:'bookDetail.jsp',
onLoad:function(){
   //赋值
   $('#ff').form('load',row);
   //重置
   $('#ff').form('reset');
}


3.Message消息窗口

  3.1 $.messager.alert

  3.2 $.messager.confirm

4.Form表单

$('#ff').form("submit",{    
    url:'',    
    onSubmit: function(){  
       //form表单验证
       return $(this).form('validate');
    },    
    success:function(data){

    }    
});

//form表单序列化
$('#ff').serialize();
  

5、sql脚本代码:

create table tb_book
(
       bid number primary key,--书籍id
       bname varchar2(100),--书籍名称
       bprice number(5,2),--书籍价格
       btype varchar2(100)--书籍类型
       
)
between
commit;
select * from tb_promission where id =12;

update tb_promission set url ='BookList.jsp' where id =12;
select * from tb


insert into tb_book(bid,bname,bprice,btype) values (1,'我爱Java',99,'都市');
insert into tb_book(bid,bname,bprice,btype) values (2,'圣墟',55,'玄幻');
insert into tb_book(bid,bname,bprice,btype) values (3,'斗罗大陆',29,'玄幻');
insert into tb_book(bid,bname,bprice,btype) values (4,'韩湘子传奇',54,'悬疑');
insert into tb_book(bid,bname,bprice,btype) values (5,'带着老婆去打妖',65,'悬疑');
insert into tb_book(bid,bname,bprice,btype) values (6,'豪门联姻之夫来收妖',123,'言情');
insert into tb_book(bid,bname,bprice,btype) values (7,'深宫有朵黑莲花',54,'言情');
insert into tb_book(bid,bname,bprice,btype) values (8,'武动乾坤',229,'玄幻');
insert into tb_book(bid,bname,bprice,btype) values (9,'金瓶梅',33,'历史');
insert into tb_book(bid,bname,bprice,btype) values (10,'我在亮剑当战狼',33,'军事');
insert into tb_book(bid,bname,bprice,btype) values (11,'菁华记之千山暮雪',33,'武侠');
insert into tb_book(bid,bname,bprice,btype) values (12,'江湖传奇传',44,'武侠');
insert into tb_book(bid,bname,bprice,btype) values (13,'大秦:不装了,你爹我是秦始皇',33,'历史');
insert into tb_book(bid,bname,bprice,btype) values (14,'西游记',33,'历史');
insert into tb_book(bid,bname,bprice,btype) values (15,'神墓',259,'玄幻');
insert into tb_book(bid,bname,bprice,btype) values (16,'我的26岁女房客',99,'都市');
insert into tb_book(bid,bname,bprice,btype) values (17,'我的校花贴身高手',12,'都市');
insert into tb_book(bid,bname,bprice,btype) values (18,'坏蛋是怎样炼成的',29,'都市');
insert into tb_book(bid,bname,bprice,btype) values (19,'很纯很暧昧',2,'都市');
insert into tb_book(bid,bname,bprice,btype) values (20,'领家有女初长成',23,'都市');
insert into tb_book(bid,bname,bprice,btype) values (21,'最强弃少',88,'都市');
insert into tb_book(bid,bname,bprice,btype) values (22,'邪气凌然',219,'都市');
insert into tb_book(bid,bname,bprice,btype) values (23,'黄金瞳',265,'都市');
insert into tb_book(bid,bname,bprice,btype) values (24,'天才相师',65,'都市');
insert into tb_book(bid,bname,bprice,btype) values (25,'陈二狗的妖孽人生',63,'都市');
insert into tb_book(bid,bname,bprice,btype) values (26,'都市奇妖谈',93,'都市');
insert into tb_book(bid,bname,bprice,btype) values (27,'白狐天下',54,'都市');
insert into tb_book(bid,bname,bprice,btype) values (28,'都市圣医',18,'都市');
insert into tb_book(bid,bname,bprice,btype) values (29,'家里养个狐狸精',438,'都市');
insert into tb_book(bid,bname,bprice,btype) values (30,'神龙至尊',22,'都市');
insert into tb_book(bid,bname,bprice,btype) values (31,'我的28岁女房东',432,'都市');
insert into tb_book(bid,bname,bprice,btype) values (32,'最强狂兵',11,'都市');
insert into tb_book(bid,bname,bprice,btype) values (33,'道诡异仙',22.99,'玄幻');
insert into tb_book(bid,bname,bprice,btype) values (34,'万古神帝',19,'玄幻');
insert into tb_book(bid,bname,bprice,btype) values (35,'万相之王',16,'玄幻');
insert into tb_book(bid,bname,bprice,btype) values (36,'最初进化',22,'玄幻');
insert into tb_book(bid,bname,bprice,btype) values (37,'核动力剑仙',33,'玄幻');
insert into tb_book(bid,bname,bprice,btype) values (38,'斗破苍穹',55,'玄幻');
insert into tb_book(bid,bname,bprice,btype) values (39,'烛龙以左',90,'玄幻');
insert into tb_book(bid,bname,bprice,btype) values (40,'遮天',1,'玄幻');
insert into tb_book(bid,bname,bprice,btype) values (41,'人族镇守使',33,'玄幻');
insert into tb_book(bid,bname,bprice,btype) values (42,'一世之尊',55,'玄幻');
insert into tb_book(bid,bname,bprice,btype) values (43,'长夜余火',229,'玄幻');
insert into tb_book(bid,bname,bprice,btype) values (44,'完美世界',5,'玄幻');
insert into tb_book(bid,bname,bprice,btype) values (45,'十方武圣',7,'玄幻');
insert into tb_book(bid,bname,bprice,btype) values (46,'神印王座',89,'玄幻');
insert into tb_book(bid,bname,bprice,btype) values (47,'牧神记',88,'玄幻');
insert into tb_book(bid,bname,bprice,btype) values (48,'奥术神座',123,'玄幻');
insert into tb_book(bid,bname,bprice,btype) values (49,'儒道至圣',45,'玄幻');
insert into tb_book(bid,bname,bprice,btype) values (50,'极品老公太难缠',54,'言情');
insert into tb_book(bid,bname,bprice,btype) values (51,'这个道士不好惹',54,'悬疑');
insert into tb_book(bid,bname,bprice,btype) values (52,'食梦貘手记',22,'悬疑');
insert into tb_book(bid,bname,bprice,btype) values (53,'修仙玩家',65,'武侠');
insert into tb_book(bid,bname,bprice,btype) values (54,'春秋煮酒',22,'武侠');
insert into tb_book(bid,bname,bprice,btype) values (55,'绝世仙缘',55,'武侠');
insert into tb_book(bid,bname,bprice,btype) values (56,'我的谍战岁月',55,'军事');
insert into tb_book(bid
  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值