复选框批量删除操作-jquery方式
1.首先在页面添加一个批量删除的按钮:<li class="btns"><input id="deleteSubmit" class="btn btn-primary" type="submit" value="批量删除"/></li>
2.在列表项中添加设置复选框:
<table id="contentTable" class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th>
<input type="checkbox" id="checkAll">全选
</th>
<th>序号</th>
<th>时间</th>
<th>姓名</th>
<th>性别</th>
<th>毕业学校</th>
</tr>
</thead>
<tbody>
<td>
<input type="checkbox" name="subBox" value="${xgStudentRegistration.id}"/>
</td>
</tbody>
</table>
2.使用jquery获取复选框选中的对应item的id
<html>
<head>
<script type="text/javascript">
$(document).ready(function() {
//全选按钮事件绑定
$(function() {
$("#checkAll").click(function() {
$('input[name="subBox"]').not("[disabled]").attr("checked",this.checked);
});
var $subBox = $("input[name='subBox']");
$subBox.click(function(){
$("#checkAll").attr("checked",$subBox.length == $("input[name='subBox']:checked").length ? true : false);
});
});
$("#deleteSubmit").click(function(){
var chk_value =[];
$('input[name="subBox"]:checked').each(function(){
chk_value.push($(this).val());
});
if(chk_value.length<=0){
alert("请选择要删除的数据!");
}else{
if(confirm("你确定删除吗?")){
var s = chk_value.join(",");
location.href = '${ctx}/student/xgStudentRegistration/deleteChosse?id='+s;
return false;
}
}
});
</script>
</head>
</html>
3.在controller中操作:
@Controller
@RequestMapping(value = "${adminPath}/student/xgStudentRegistration")
public class XgStudentRegistrationController extends BaseController {
@RequiresPermissions("student:xgStudentRegistration:edit")
@RequestMapping(value = "deleteChosse")
public String deleteChosse(XgStudentRegistration xgStudentRegistration, RedirectAttributes redirectAttributes,String id) {
xgStudentRegistrationService.deleteChosse(id);
addMessage(redirectAttributes, "删除信息成功");
return "modules/xg/student/xgStudentRegistrationList";
}
}
4.在service中操作:
public class XgStudentRegistrationService extends CrudService<XgStudentRegistrationDao, XgStudentRegistration>{
@Transactional(readOnly = false)
public void delete(XgStudentRegistration xgStudentRegistration) {
super.delete(xgStudentRegistration);
}
public void deleteChosse(String id) {
String[] list = id.split(",");
XgStudentRegistration xgStudentRegistration = new XgStudentRegistration();
for (String i : list) {
xgStudentRegistration.setId(i);
delete(xgStudentRegistration);
}
}
}
public abstract class CrudService<D extends CrudDao<T>, T extends DataEntity<T>> extends BaseService {
/**
* 持久层对象
*/
@Autowired
public D dao;
/**
* 删除数据
* @param entity
*/
@Transactional(readOnly = false)
public void delete(T entity) {
dao.delete(entity);
}
}
**
* 学生咨询登记DAO接口
* @author gh
* @version 2017-05-15
*/
@MyBatisDao
public interface XgStudentRegistrationDao extends CrudDao<XgStudentRegistration> {
}
5.在xml中delete
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.student.dao.XgStudentRegistrationDao">
<update id="delete">
UPDATE xg_student_registration SET
del_flag = #{DEL_FLAG_DELETE}
WHERE id = #{id}
</update>
</mapper>
tag:
jquery中的$(document).ready(function() {})这句话是什么 意思
这部分代码主要声明,页面加载后 “监听事件” 的方法。
例如:
$(document).ready(
$("a").click(function(){alert('你点我干嘛')});
);
这句的意思是:
页面加载成功后,页面内的所有链接在“点击”事件的时候,提示“你点我干嘛”。
文档就绪事件
所有 jQuery 函数位于一个 document ready 函数中:
这是为了防止文档在完全加载(就绪)之前运行 jQuery 代码。
如果在文档没有完全加载之前就运行函数,操作可能失败。下面是两个具体的例子:
- 试图隐藏一个不存在的元素
- 获得未完全加载的图像的大小
提示:简洁写法(与以上写法效果相同):
$(function(){ // 开始写 jQuery 代码... });
以上两种方式,选择喜欢的方式实现文档就绪后执行 jQuery 方法。
复选框批量删除操作-jquery方式的更多相关文章
- angularJS批量删除 品优购删除品牌(通用复选框批量选中删除解决思路)
思路: 一步:在点击复选框时维护变量数组 在js中定义一个数组变量, 给复选框添加点击动作, 在动作中判断当前复选框是否为选中状态(即点击后复选框的是否选中状态), 若为选中状态,则向数组中添加选中的 ...
- jquery对复选框(checkbox)的操作(精华)
@{ Layout = null;} <!DOCTYPE html> <html><head> <meta name="viewport" ...
- Jquery对复选框CheckBox的操作
checkbox: 多选框 //获取选中值 checkbox:$("#checkbox_id").attr("value"): 多选框checkbox,打勾: ...
- 我在DBGridEh增加一栏复选框及对应操作的解决方案
最近客户有个需求,要求对单据列表里指定的单据进行批量审核,很自然的,我想到了在DBGridEh增加一栏复选框的列,审核时遍历所有单据,将打了勾的单据审核就可以了.查阅了网上很多文章,不外有2个方案,1 ...
- android 中单选和复选框监听操作
单选按钮RadioGroup.复选框CheckBox都有OnCheckedChangeListener事件,我们一起了解一下. package com.genwoxue.oncheckedchange ...
- springmvc+mybatis用多选框批量删除的功能Java代码
今天写了一个批量删除的功能,在后台传值过程中一直出错,最终还是请教了北京的一位高手帮我解决的,在此首先要好好感谢他,以后我有幸能帮助别人的话,决不推辞. 废话不说,直接进入正题,我会将在编写过程中出现 ...
- jQuery操作复选框的简单使用
开发中为了实现一个小功能,就是复选框的相互影响事件,如下图: 就是通过复选框设置权限,权限是分等级的,这是一个web管理系统的应用,一个管理员具有三个权限赋予,权限也是有等级的,其中删除和编辑权限相当 ...
- 关于我们的Jquery操作下拉列表和复选框,自定义下拉
后半部分还有自定义下拉列表和开灯关灯的效果,可以进来来看一下 哦 如果网页有下拉列表和复选框,看一下Jquery怎么来操作他们,主要怎么来选取他们的数据,怎么设置某一项选中 先来看个下拉列表 < ...
- Jquery操作下拉列表和复选框,自定义下拉
后半部分还有自定义下拉列表和开灯关灯的效果,可以进来来看一下 哦 如果网页有下拉列表和复选框,看一下Jquery怎么来操作他们,主要怎么来选取他们的数据,怎么设置某一项选中 先来看个下拉列表 < ...
随机推荐
- 家庭记账本之Github账号注册与安装(二)
好多程序猿都在使用github用来存放自己的代码:但是如果仅仅用github的web版本的话:有一些功能还是需要使用git客户端工具才能操作的: 那么今天将指导大家如何安装GitHub for win ...
- Linux和windows 查看程序、进程的依赖库的方法
Linux: 1. 利用ldd查看可执行程序的依赖库 [root@~]# ldd /usr/local/php/bin/php linux-vdso.so.1 => (0x00007ff ...
- glibc源码下载
https://www.gnu.org/software/libc/ Download sources Releases are available by source branch checkout ...
- 微信公众号支付(JSAPI)对接备忘
0 说明 本文里说的微信公众号支付对接指的是对接第三方支付平台的微信公众号支付接口. 非微信支付官方文档里的公众号支付开发者文档那样的对接.不过,毕竟腾讯会把一部分渠道放给银行或有支付牌照的支付机构, ...
- activity bj draw 流程图
- HAProxy实现mysql负载均衡
安装 yum install haproxy 修改配置 vi /etc/haproxy/haproxy.cfg 配置如下 global daemon nbproc 1 pidfile /var/r ...
- [9]Windows内核情景分析 --- DPC
DPC不同APC,DPC的全名是'延迟过程调用'. DPC最初作用是设计为中断服务程序的一部分.因为每次触发中断,都会关中断,然后执行中断服务例程.由于关中断了,所以中断服务例程必须短小精悍,不能消耗 ...
- 用Hexo在GitHub上搭建个人博客
我用Hexo在GitHub上搭建好了自己的博客,我的这第一篇博客就来说说搭建的过程. 1 环境配置 本文使用环境如下: Windows 10 node.js v8.1.3 git v2.13.2 np ...
- hdu5032 树状数组
题意: 对于一个1000*1000的Mushroom, 起点在(1,1)给定一个斜率和一个x,求由斜率和x所对应的直线构成的三角形内蘑菇的总值. 每个点的对应的值为(x+A)(y+B) 解 每个点都有 ...
- SQL性能优化前期准备-清除缓存、开启IO统计
文章来至:https://www.cnblogs.com/Ren_Lei/p/5669662.html 如果需要进行SQl Server下的SQL性能优化,需要准备以下内容: 一.SQL查询分析器设置 ...