• jqgrid自带多选与单选


    {include file="public/header"/}
    
    
    
    <div class="container" style="margin:10px 20px;">
       
        <div class="grid-wrap">
            <table id="grid">
            </table>
            <div id="page"></div>
        </div>
    </div>
    
    <script src="/public/static/admin/easyui/layui-v2.6.8/layui.js"></script>
    <script type="text/javascript" src="/public/static/admin/easyui/jeasyui/jquery.easyui.min.js"></script>
    
    <script>
        $(document).ready(function () {
    
            $("#grid").jqGrid({
                url:'/admin/basic/choose_source_list.html?ajax=100',
                datatype: "json",//数据来源,本地数据(local,json,jsonp,xml等)
                height:'290px',//高度,表格高度。可为数值、百分比或'auto'
                // Public.setGrid().w,
                //height: Public.setGrid().h,
                colNames: [ "源单编号", "业务类别", "单据日期", "单据金额","已核销金额","未核销金额","备注",'ID'],
                colModel:[
                    {name:'sn', 120,lable:'源单编号'},
                    {name:'o_type_name', 80,lable:'业务类别'},
                    {name:'dj_time', 70,lable:'单据日期'},
                    {name:'dj_jine', 100,lable:'单据金额'},
                    {name:'already_jine', 100,lable:'已核销金额'},
                    {name:'not_jine', 100,lable:'未核销金额'},
                    {name:'mark', 150,lable:'备注'},
                    {name:'id', hidden:true},
                   ],
                  
                 rowNum:10,
                 rowList:[10,20,30],
                 sortname: 'id',
                 sortorder: "desc",
                 pagerpos:"left",//分页位置
                 
                 pgbuttons:true,//翻页按钮
                 pagination:true,
                 altRows: !0,
                gridview: !0,
                shrinkToFit: !1,
                cellLayout: 8,
                auto !0,
                pager: "#page",
                viewrecords: !0,
                checkOnSelect: true,
                multiselect:true,//自带多选
                //multiboxonly:true,//变成单选
                cmTemplate: {
                    sortable: !1,
                    title: !1
                },
                loadError: function(t, e, i) {
                    parent.Public.tips({
                        type: 1,
                        content: "操作失败了哦,请检查您的网络链接!"
                    })
                },
                gridComplete: function() {
                    var rowIds = $("#grid").jqGrid('getDataIDs');
                    for(var k=0; k<rowIds.length; k++) {
                       var curRowData = $("#grid").jqGrid('getRowData', rowIds[k]);
                       var curChk = $("#"+rowIds[k]+"").find(":checkbox");
                       curChk.attr('name', 'checkboxname');   //给每一个checkbox赋名字
                       curChk.attr('value', curRowData['id']);   //给checkbox赋值
                       //curChk.attr('title', curRowData['id'] );   //给checkbox赋予额外的属性值
                       //curChk.attr('checked', 'true');   //设置所有checkbox被选中
                    }
                },
               });
    
        });
    
    
    
    </script>
    <script type="text/javascript">
        function aaa(){
    
            //判断是否至少有一个选中
            if($('.cbox').is(':checked')) {
                console.log("111");
            }else{
                console.log("000");
            }
            var ids = [];
            $("#grid input:checkbox[name='checkboxname']:checked").each(function(i){
               ids.push($(this).val());
               //ids.push($(this).attr("title"));
            });
            console.log(ids);
         for(var p=0; p<ids.length; p++){
            alert(ids[p]);
         } }
    </script> {include file="public/footer"/}
  • 相关阅读:
    css面试题目
    5. React-Router05 BrowserRouter 和hashrouter
    5. React-Router03 withRouter
    5. React-Router01
    CVE-2019-0708—微软RDP远程桌面代码执行漏洞复现
    正则表达式学习汇总
    CTF---PHP安全考题
    快速搭建主动诱导型开源蜜罐框架系统--hfish
    python--爬取网页存在某字符
    Linux 实用指令之查看端口开启情况
  • 原文地址:https://www.cnblogs.com/zhangyouwu/p/15178890.html
Copyright © 2020-2023  润新知