当前位置:网站首页>EasyUI DataGrid control uses
EasyUI DataGrid control uses
2022-07-25 16:44:00 【Sooner or later, I will go bald】
datagrid Control use
1. The goal is
Display the data of the database to tabs On the page , And provide query and paging
design sketch :
** After deleting, modifying and adding, we will talk about today's query and presenting data to the table :
First of all, we understand datagrid Control
Is a data table control : And it has its own paging attribute
jsp Write a table label and toolbar in the interface
// form
js Interface
$(function() {})// Automatic operation
datagrid It needs to be written in self operation **
$('#dg').datagrid({
// Data file read file path
url : $("#ctx").val() + '/book.action?methodName=books',
// Paging toolbar properties
pagination : true,
// Real auto expand / Shrink the size of the column , To fit the width of the grid , Prevent horizontal scrolling .
fitColumns : true,
// Define toolbar I define search and add buttons here
toolbar : '#tb',
// listed
columns : [ [ {
//field Is to read data files , Properties must be the same to be read
field : 'bid',
title : 'id',
width : 100
}, {
field : 'bname',
title : ' name ',
width : 100
}, {
field : 'price',
title : ' Price ',
width : 100
}, {
field : ' operation ',
title : ' operation ',
width : 100,
align : "right",
formatter : function(value, row, index) {
return "<a href='javascript:void(0);' οnclick='xg()'> modify </a>" +
" <a href='javascript:void(0);' οnclick='del()'> Delete </a> "
}
}
] ]
})
The latter is to transfer the background data to js coming
How to get data
public List<Book> executeQuery(Book book, PageBean pageBean) throws Exception {
String bname = book.getBname();
String sql = "select * from t_mvc_book where 1=1";
// If you pass the name, add a fuzzy query statement
if (StringUtils.isNotBlank(bname)) {
sql += " and bname like '%" + bname + "%'";
}
return super.executeQuery(sql, Book.class, pageBean);
}
Translate data into datagrid Need the form and send
public String books(HttpServletRequest req, HttpServletResponse resp) throws Exception {
// Paging properties
PageBean pageBean = new PageBean();
// Pass pages in
// stay easyui in , Click next page, previous page and other default paging effects , The parameters carried are page/rows
// I packaged it pageBean Just these two properties
pageBean.setRequest(req);
// Get all the data in the database
List<Book> list = bookdao.executeQuery(book, pageBean);
// Change the data into the required format
Map<String, Object> map = new HashMap<String, Object>();
map.put("total", pageBean.getTotal());
map.put("rows", list);
// Convert data to josn And send it back
ResponseUtil.writem(resp, map);
return null;
}
Search function
Set click events for search
load Send data to the background
And the front dao Package method corresponds to
$("#btn-search").click(function() {
$('#dg').datagrid('load', {
bname : $("#bname").val()
});
})
result :

边栏推荐
猜你喜欢

自定义mvc项目登录注册和树形菜单

Who moved my memory and revealed the secret of 90% reduction in oom crash

easyui下拉框,增加以及商品的上架,下架

伦敦银K线图的各种有用形态
![[image denoising] image denoising based on bicube interpolation and sparse representation matlab source code](/img/39/716c62d6ca533a7e84704b2c55d072.png)
[image denoising] image denoising based on bicube interpolation and sparse representation matlab source code

Rebudget汇报PPT

简述redis集群的实现原理

Rebudget: balance efficiency and fairness in market-based multi-core resource allocation by reallocating the budget at run time

ReBudget:通过运行时重新分配预算的方法,在基于市场的多核资源分配中权衡效率与公平性

【故障诊断】基于贝叶斯优化支持向量机的轴承故障诊断附matlab代码
随机推荐
01. A simpler way to deliver a large number of props
80篇国产数据库实操文档汇总(含TiDB、达梦、openGauss等)
ReBudget:通过运行时重新分配预算的方法,在基于市场的多核资源分配中权衡效率与公平性
伦敦银K线图的各种有用形态
Test framework unittest test test suite, results output to file
测试驱动开发(TDD)在线练功房 | 9月17日开课
Register service instances in ngmodule through dependency injection
Test Driven Development (TDD) online practice room | classes open on September 17
MyBaits
slf4j 搭配 log4j2 处理日志
ILSSI认证|六西格玛DMAIC的历程
百度富文本编辑器UEditor单张图片上传跨域
Promise date
Roson的Qt之旅#99 QML表格控件-TableView
Verifiable random function VRF
Fudan University emba2022 graduation season - graduation does not forget the original intention and glory to embark on the journey again
7. Dependency injection
2D semantic segmentation -- deeplabv3plus reproduction
测试框架-unittest-命令行操作、断言方法
聊聊如何用 Redis 实现分布式锁?