------------------------------------------------------------------------------------------------------------
.jsp
------------------------------------------------------------------------------------------------------------
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>customer</title>
<meta charset="utf-8"/>
<link rel="stylesheet"
href="../jquery-easyui-1.3.4/themes/default/easyui.css" />
<link rel="stylesheet" href="../jquery-easyui-1.3.4/themes/icon.css" />
<script src="../jquery-easyui-1.3.4/jquery.min.js"></script>
<script src="../jquery-easyui-1.3.4/jquery.easyui.min.js"></script>
<script src="../jquery-easyui-1.3.4/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="./js/policy.js"></script>
<script type="text/javascript" src="./js/rules.js"></script>
<script type="text/javascript" src="./js/CardRules.js"></script>
<script type="text/javascript">
//获取登录用户
urlinfo=window.location.href;
len=urlinfo.length;
offset=urlinfo.indexOf("?");
newsidinfo=urlinfo.substr(offset,len);
newsids=newsidinfo.split("=");
newsid=newsids[1];
$(function(){
$("#dataGrid").datagrid({
checkbox:true,
fitColumns:true,
checkbox:true,
pagination:true,
pagePosition:'bottom',
pageList:[10,20,30],
pageSize:10,
url:'../BaseServlet?method=getAll&table=material',
columns:[[
{field:'check',title:'选择',100,formatter:function(value,row,index){
return "<input type='checkbox' name='operCheck' value='"+row.mname+"' />";
}},
{field:'mid',title:'材料编号',80},
{field:'mname',title:'材料名称',80,},
{field:'mbrand',title:'材料品牌',80},
{field:'mpay',title:'单价(元)',80},
]],
singleSelect:true,
toolbar:[{
text:'选择',
iconCls:'icon-edit',
handler:function(){
var selected=$("#dataGrid").datagrid('getSelected');
if(selected==null){
$.messager.alert('messages','请选中行!');
return;
}
$.messager.confirm('您选择了:',''+getSelOperids(),function(r){
if (r){
$.post("../MaterialServlet?method=mod2&objs="+getSelOperids()+"&userid="+newsid,
function(data){
});
}
});
}
}
]
});
});
$(function(){
$("#dataGrid").datagrid({
toolbar:'#searchtool'
});
});
//得到表格浮选框,选中的操作员id数组
function getSelOperids(){
var operids=new Array();
var ind=0;
//删除操作
$("[name='operCheck']").each(function(index){
if(this.checked==true){
operids[ind++]=$(this).val();
console.log(operids[ind-1]);
}
});
return operids;
}
</script>
</head>
<body>
<table id="dataGrid"></table>
</body>
</html>
------------------------------------------------------------------------------------------------------------
.java
------------------------------------------------------------------------------------------------------------
if("mod2".equals(method)){
// String strs=request.getParameter("objs");
String strs = new String(request.getParameter("objs").getBytes("iso-8859-1"),"utf-8");
String userid = new String(request.getParameter("userid"));
System.out.println("----"+strs+"====="+userid);
List<Object> params = new ArrayList<Object>();
params.add(strs);
String sql = "update plan set pdescribe=? where cid="+userid;
Object addObj = baseService.operObj(sql, params);
int count=1;
if(addObj==null){
count=0;
}
out.print("{"count":"+count+"}");
}