zoukankan      html  css  js  c++  java
  • dataGrid设置checkbox方法

    ------------------------------------------------------------------------------------------------------------

    .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+"}");
                
            }

  • 相关阅读:
    SpringBoot 集成Log4j、集成AOP
    SpringBoot 集成JUnit
    SpringBoot yml文件语法
    SpringBoot 集成MyBatis、事务管理
    SpringBoot 集成Spring JDBC
    模板引擎简介
    SpringBoot 解决“不支持发行版本xx”的问题
    SpringBoot 全局异常处理
    SpringBoot 静态资源的配置
    SpringBoot的起步依赖
  • 原文地址:https://www.cnblogs.com/super-admin/p/5427159.html
Copyright © 2011-2022 走看看