博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
jqgride实现多选
阅读量:6901 次
发布时间:2019-06-27

本文共 5728 字,大约阅读时间需要 19 分钟。

<!DOCTYPE html>

<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
<meta http-equiv=Content-Type content="text/html;charset=utf-8">
<script>var wpo={start:new Date*1,pid:109,page:'superpage'}</script>
<meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1" />
<meta http-equiv="X-UA-Compatible" content="IE=9" />
<link rel="stylesheet" type="text/css" href="common/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="common/css/common.css" />
<link href="common/css/jqgrid/ui.jqgrid.css" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="common/css/bootstrap-select/bootstrap-select.css">
<link rel="stylesheet" type="text/css" href="common/css/bootstrap-checkbox/bootstrap-checkbox.css">
<link href="common/css/datapicker/datepicker3.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="common/css/projectSelect.css" />
<script src="common/js/jquery.min.js"></script>
<script src="common/js/bootstrap.min.js"></script>
<script src="common/js/jqgrid/jquery.jqGrid.min.js"></script>
<script src="common/js/jqgrid/i18n/grid.locale-cn.js"></script>
<script src="common/js/layer/layer.min.js"></script>
<script src="common/js/jquery.form.js"></script>
<script src="common/js/datapicker/bootstrap-datepicker.js"></script>

<script>

var $OrderStayjqGrid;
$(function() {
//初始化grid
$OrderStayjqGrid = jqGridInit();
$OrderStayjqGrid.Init();
$("#gbox_orderstay_jqGrid").width();
});
// 设置jqgrid的宽度
$(window).bind('resize', function () {
var width=$(".tablesty").width();
width=window.innerWidth-20;
});
//重置grid宽高
//初始化grid
function jqGridInit(){
var jqGridInit = new Object();
var search = $('div[class=search_panel]').height();
var height = 300;
//初始化grid
jqGridInit.Init = function(){

jqGridInit.grid = jQuery("#orderstay_jqGrid").jqGrid({

datatype : "local",
jsonReader : {
root:"data",
page: "pageIndex",
total: "totalPage",
records: "totalCount",
repeatitems:false
},
styleUI: 'Bootstrap',//设置jqgrid的全局样式为bootstrap样式
colNames:['第一列','第二列','第三列'],
sortable: false,
colModel:[
{
name:"answerGroupName",
index:"answerGroupName",
width:80,
classes: "answerGroupName",
sortable: false,
},{
name:"answerGroupCode",
index:"answerGroupCode",
width:200,
classes: "answerGroupCode",
// hidden: true,
sortable: false,
}, {
name:"askAnswers",
index:"askAnswers",
width:600,
classes: "askAnswers",
sortable: false,
// formatter: function(_val,_o,_i){
// var askAnswers = _i.askAnswers;
// var arr = [];
// $.each(askAnswers,function(x,y){
// arr.push(y.answerDescribe)
// })
// return '<span>'+arr+'</span>'
// },
}],
viewrecords: true, //是否显示行数
multiselect: true, //是否支持多选
// rownumbers: true, //序号
autowidth:false,
height:height,
// shrinkToFit:true,
rowNum: 3,
pager: "#orderstay_toolber",

onSelectRow: function (rowId, status, e) {
var rowIds = jQuery("#orderstay_jqGrid").jqGrid('getGridParam', 'selarrrow');
},
})
$("#orderstay_jqGrid").closest(".ui-jqgrid-bdiv").css({ 'overflow-y' : 'scroll'});
$("#first_orderstay_toolber").html("首页");
$("#prev_orderstay_toolber").html("前一页");
$("#next_orderstay_toolber").html("下一页");
$("#last_orderstay_toolber").html("末页");
var mydata = [
{id : "1",answerGroupName : "2007-10-01",answerGroupCode : "test",askAnswers : "note",amount : "200.00",tax : "10.00",total : "210.00"},
{id : "2",answerGroupName : "2007-10-02",answerGroupCode : "test2",askAnswers : "note2",amount : "300.00",tax : "20.00",total : "320.00"},
{id : "3",answerGroupName : "2007-09-01",answerGroupCode : "test3",askAnswers : "note3",amount : "400.00",tax : "30.00",total : "430.00"},
{id : "4",answerGroupName : "2007-10-04",answerGroupCode : "test",askAnswers : "note",amount : "200.00",tax : "10.00",total : "210.00"},
{id : "5",answerGroupName : "2007-10-05",answerGroupCode : "test2",askAnswers : "note2",amount : "300.00",tax : "20.00",total : "320.00"},
{id : "6",answerGroupName : "2007-09-06",answerGroupCode : "test3",askAnswers : "note3",amount : "400.00",tax : "30.00",total : "430.00"},
{id : "7",answerGroupName : "2007-10-04",answerGroupCode : "test",askAnswers : "note",amount : "200.00",tax : "10.00",total : "210.00"},
{id : "8",answerGroupName : "2007-10-03",answerGroupCode : "test2",askAnswers : "note2",amount : "300.00",tax : "20.00",total : "320.00"},
{id : "9",answerGroupName : "2007-09-01",answerGroupCode : "test3",askAnswers : "note3",amount : "400.00",tax : "30.00",total : "430.00"}
];
for ( var i = 0; i <= mydata.length; i++){
jQuery("#orderstay_jqGrid").jqGrid('addRowData', i + 1, mydata[i]);
}

}

return jqGridInit;
}
function secFn(i){
$(i).parent().parent().addClass("success");
$(i).parent().parent().attr("aria-selected",true);
$(i).parent().parent().siblings().removeClass("success");
$(i).parent().parent().siblings().attr("aria-selected",false)
}

function confirm() {

var list=[];
var obj=$('#orderstay_jqGrid').find(".success");
for(var i = 0;i<obj.length;i++) {
list.push({code: $(obj[i]).find('.answerGroupCode').attr('title')});
}
alert('选中的长度为:'+list.length)
console.log(list);
}

</script>

</head>
<body >

<div id="orderstay_wrapper" style="width:750px;height:100px;padding-top:20px;padding-left: 20px;padding-right:20px;margin: auto ">

<!--jqgride表格-->
<table id="orderstay_jqGrid" ></table>
<!--页码-->
<div id="orderstay_toolber"></div>
</div>

<div class="btn btn-primary" οnclick="confirm()">确定</div>
</body>
<style>
.btn{
margin-left: 80%;
margin-top: 400px;
}
.ui-jqgrid-sortable{
font-size:10px;
}
table{
border-radius: 0px!important;
margin-bottom: 0!important;
}
.answerGroupName{
font-size:10px;
padding-left: 10px;
}
.askAnswers{
font-size:10px;
padding-left: 10px;
}
.ui-jqgrid .ui-pg-table td{
font-size: 10px;
color:black;
}
</style>
</html>

 

转载于:https://www.cnblogs.com/xy-milu/p/9298182.html

你可能感兴趣的文章
麒麟开源堡垒机集中管控平台软件简介
查看>>
第十一单元练习
查看>>
从零开始的linux 第十六章
查看>>
EOS内存RAM是如何买卖的
查看>>
微服务架构中zuul的两种隔离机制实验
查看>>
电子合同将取代纸质合同吗?
查看>>
官宣丨“创客集结号”成功接入“广东省教育资源公共服务平台”!
查看>>
oracle教程之DML语句与undo
查看>>
mock.js与json schema
查看>>
转:Java properties | FileNotFoundException: properties (系统找不到指定的文件。)
查看>>
Cpp中流继承关系
查看>>
Angular CLI 使用教程指南参考
查看>>
[设计模式之禅读书笔记]001_设计模式六大原则(一):单一职责原则(Single Responsibility Principle)...
查看>>
CSAPP:cachelab(1)
查看>>
时间序列识别代码调试版本1
查看>>
Tomcat内存溢出解决办法
查看>>
Vue:v-model指令
查看>>
Software Engineering | Strategy pattern
查看>>
ios开发系列-准备工作
查看>>
Android Studio调试手机或者安装APK的时候出现install failed test only
查看>>