jsJqGrid
/*展开收起*/ $(function() { initGridTable(); }); function change() { var flag = $("#searchTitle").attr("flag"); if (flag == 'show') { $("#searchDiv").slideUp(); $("#searchTitle > span:first").text("展开"); $("#searchTitle").find("i").removeClass("fa-minus").addClass("fa-plus") .end().attr("flag", "hide"); } else { $("#searchDiv").slideDown(); $("#searchTitle > span:first").text("收起"); $("#searchTitle").find("i").removeClass("fa-plus").addClass("fa-minus") .end().attr("flag", "show"); } }; function initGridTable() { // start grid table var grid_selector = "#grid-table-period"; var pager_selector = "#grid-pager"; // resize to fit page size $(window).unbind("resize.jqGrid"); $(window).on('resize.jqGrid', function() { /* * if(window.screen.width <= 1366){ * $(grid_selector).jqGrid('setGridWidth', * $(".page-content").width()).jqGrid('setGridHeight', * $(window).height()-305); }else { * $(grid_selector).jqGrid('setGridWidth', * $(".page-content").width()).jqGrid('setGridHeight', * $(window).height()-340); } */ var tableHeight = 0; if (window.screen.width <= 1366) { tableHeight = $(window).height() - 300; } else { tableHeight = $(window).height() - 340; } $(grid_selector).jqGrid('setGridWidth', $(".page-content").width()); $(grid_selector).parents('div.ui-jqgrid-bdiv').css({ 'height' : 'auto', 'min-height' : tableHeight + 'px' }); }) // resize on sidebar collapse/expand var parent_column = $(grid_selector).closest('[class*="col-"]'); $(document).unbind("settings.ace.jqGrid"); $(document).on( 'settings.ace.jqGrid', function(ev, event_name, collapsed) { if (event_name === 'sidebar_collapsed' || event_name === 'main_container_fixed') { // setTimeout is for webkit only to give time for DOM // changes and then redraw!!! setTimeout(function() { $(grid_selector).jqGrid('setGridWidth', parent_column.width()); }, 0); } }) $(grid_selector).jqGrid( { // direction: "rtl", url : webroot + "interactive/queryAnchorMonitor.htm", datatype : "json", /* height: 350, */ colNames : [ "ID", "主播ID", "主播昵称", "禁播状态", "禁播期限", "禁播原因", "操作人", "操作时间" ], colModel : [ { name : 'id', index : 'id', width : 60, sortable : true }, { name : 'anchorId', index : 'anchorId', width : 60, sortable : true }, { name : 'anchorName', index : 'anchorName', width : 60, sortable : true }, /* * { name : 'limitStatus', index : 'limitStatus', hidden : * false, editable : true, }, */ { name : 'limitStatus', index : 'limitStatus', width : 60, sortable : true, formatter : function(cellvalue, options, rowObject) { if (cellvalue == '0') { return "正常直播"; } else if (cellvalue == '1') { return "禁播"; } else if (cellvalue == '2') { return "永久禁播"; } else { return "未知"; } } }, { name : 'limitTime', index : 'limitTime', width : 60, sortable : true }, { name : 'operatorReason', index : 'operatorReason', width : 60, sortable : true, width: 100, align: "center", sortable: false, editable: false, formatter: function(value,row,index){return '<img src= pages/interactive/img/3.png />'}, }, { name : 'operator', index : 'operator', width : 60, sortable : true, align:"center", /* */ editable:true,edittype:'select',editoptions:{value:{1:'正常', 2:'维修', 3:'常用'}}, }, { name : 'operatorTime', index : 'operatorTime', width : 60, sortable : true, } ], cellEdit: true, cellsubmit: "clientArray", sortable : true, viewrecords : true, rowNum : 20, rowList : [ 20, 100, 500, 1000 ], pager : pager_selector, altRows : true, // toppager: true, jsonReader : { total : 'total', records : 'records', root : 'rows', repeatitems : true }, /*pagepos:left,*/ multiselect : true, //复选框 // multikey: "ctrlKey", multiboxonly : true, // recordpos: 'left', 控制记录条数放在页面的位置,默认right //viewrecords: false, 隐藏记录条数 /* ondblClickRow: function (id) { jQuery('#grid-table-period').jqGrid('restoreRow', lastsel); jQuery('#grid-table-period').jqGrid('editRow', id, true); lastsel = id; }, editurl: "JqGridHandler.ashx" ,//这个文件需要有,但里面无需写任何处理代码 */ loadComplete : function(data) { var table = this; var pageNow = $(grid_selector).jqGrid('getGridParam', 'page');// 当前页 var totalPage = data.total;// 总页数 if (totalPage == 0) { $(".ui-pg-input").val(0); $("td.ui-corner-all").addClass("ui-state-disabled"); } else { if (pageNow > totalPage) { var pageInfo = ($(".ui-pg-selbox").val() * (totalPage - 1) + 1) + " - " + data.records + "\u3000共 " + data.records + " 条"; if (totalPage == 1) { $("td.ui-corner-all").addClass( "ui-state-disabled"); } $(".ui-pg-input").val(totalPage); $(grid_selector).jqGrid('setGridParam', { page : totalPage }); $("#grid-pager_right > div").text(pageInfo); $("#next_grid-pager").addClass("ui-state-disabled") .next().addClass("ui-state-disabled"); } } setTimeout(function() { updatePagerIcons(table); enableTooltips(table); }, 0); }, editurl : "/dummy.html",// nothing is saved }); $(window).triggerHandler('resize.jqGrid');// trigger window resize to make // the grid get the correct size //隐藏员工列表标题 $("#grid-table-period").closest(".ui-jqgrid-view").find("div.ui-jqgrid-titlebar").hide(); //隐藏员工列表表头 //$("#grid-table-period").closest(".ui-jqgrid-view").find("div.ui-jqgrid-hdiv").remove(); $("#grid-table-period").jqGrid('navGrid', '#grid-pager'),{ /*add:"true" , edit:"true", del:"true", search:"true", searchtext:"查找" , edittext:"编辑", deltext:"删除", addtext:"增加",*/ }; function updatePagerIcons(table) { var replacement = { 'ui-icon-seek-first' : 'ace-icon fa fa-angle-double-left bigger-140', 'ui-icon-seek-prev' : 'ace-icon fa fa-angle-left bigger-140', 'ui-icon-seek-next' : 'ace-icon fa fa-angle-right bigger-140', 'ui-icon-seek-end' : 'ace-icon fa fa-angle-double-right bigger-140' }; $('.ui-pg-table:not(.navtable) > tbody > tr > .ui-pg-button > .ui-icon') .each( function() { var icon = $(this); var $class = $.trim(icon.attr('class').replace( 'ui-icon', '')); if ($class in replacement) icon.attr('class', 'ui-icon ' + replacement[$class]); }) } function enableTooltips(table) { $('.navtable .ui-pg-button').tooltip({ container : 'body' }); $(table).find('.ui-pg-div').tooltip({ container : 'body' }); } $(document).one('ajaxloadstart.page', function(e) { $(grid_selector).jqGrid('GridUnload'); $('.ui-jqdialog').remove(); }); } var img; /* 删除按钮 */ function delAnchorMonitor() { var selectedIds = $("#grid-table-period").jqGrid("getGridParam", "selarrrow"); //返回选中多行ids if (selectedIds == '' || selectedIds == null) { alertmsg("warning",$("#sys-error-selectOne").val()); } else if (selectedIds.length >= 1) { Lobibox.confirm({ title: $("#material-alert").val(), msg: $("#interactive-confirmDel").val(), callback: function ($this, type, eve) { if(type == "yes"){ var ids = ""; for (var i=0; i<selectedIds.length; i++) { var id = selectedIds[i]; var rowData = $('#grid-table-period').getRowData(id); var inteId = rowData.id; ids = ids +inteId + ","; } console.log(ids); var data = {"inteIds":ids}; $.post(webroot + "interactive/delAnchorMonitor.htm", data, function(data){ if(data.success == true){ $("#grid-table-period").jqGrid('setGridParam',{ page:1, mtype:"post" }).trigger("reloadGrid"); //重新载入 alertmsg("success",$("#interactive-del-success").val()); }else{ alertmsg("error",$("#interactive-del-fail").val()); } } ); } } }); } } /* 编辑按键 */ function editAnchors() { var selectedIds = $("#grid-table-period").jqGrid("getGridParam", "selarrrow"); // 返回选中多行ids for (var i = 0; i < selectedIds.length; i++) { console.log(selectedIds[i]); } if (selectedIds == '' || selectedIds == null) { alertmsg("warning", $("#sys-error-selectOne").val()); } else if (selectedIds.length > 1) { alertmsg("warning", $("#sys-error-onlyOne").val()); } else { var id = $('#grid-table-period').jqGrid("getCell", selectedIds, "id"); var anchorName = $('#grid-table-period').jqGrid("getCell", selectedIds, "anchorName"); var anchorId = $('#grid-table-period').jqGrid("getCell", selectedIds, "anchorId"); var select = $('#grid-table-period').jqGrid("getCell", selectedIds, "limitStatus"); $("#Id").val(id); $("#anchorId").val(anchorId); $("#anchorName").val(anchorName); $("#editAnchorsModal").modal("show"); $("#select").val(caseChange(select)); $("#limitDay").hide(); $("#limitReason").show(); if (caseChange(select) == 1) { $("#limitDay").show(); }; if (caseChange(select) == 0) { $("#limitReason").hide(); }; } }; function caseChange(e) { if (e == "正常直播") { return 0; } else if (e == "禁播") { return 1; } else if (e == "永久禁播") { return 2; } else { return 0; } ; } /* 保存修改 */ function editSaveAnchorMonitor() { var selectedIds = $("#grid-table-period").jqGrid("getGridParam", "selarrrow"); // 返回选中多行ids var Id = $("#Id").val(); var anchcorName = $("#anchorName").val(); var anchcorId = $("#anchorId").val(); var limitStatus = $("#select option:selected").val(); var limitTime = $("#limitTime").val(); var operatorReason=$("#limitReasonText").val(); if (limitStatus == 1) { if (limitTime == "" || limitTime == null || limitTime == undefined) { alert("天数不能为空,请重新输入"); return; } ; } ; // 将这三个值传到action,经后台处理后返回到前台 var jsonData = { 'id' : Id, 'anchcorName' : anchcorName, 'anchcorId' : anchcorId, 'limitStatus' : limitStatus, 'limitTime' : limitTime, 'operatorReason':operatorReason, }; $.ajax({ type : "post", url : webroot + "interactive/saveAnchorMonitor.htm", data : jsonData, success : function(data) { if (data.msg == true) { alertmsg("success", "编辑成功"); $("#grid-table-period").jqGrid('setGridParam', { page : 1, mtype : "post" }).trigger("reloadGrid"); // 重新载入 } else { alertmsg("error", "编辑失败"); } } }); $("#editAnchorsModal").modal("hide"); $('#saveEditForm')[0].reset(); setBtnDisable(e)// set search button disabled and remove the disabled }; /* 根据主播ID或名字查询主播信息 */ function searchAnchorMonitor() { /* var anchorTableId =document.getElementById("anchorTableId") */ var anchorTableId = $("#anchorTableId").val(); var anchorName = $("#anthorName").val(); var limintStatus = $("#searchOption").val(); if (isNaN(anchorTableId)) { alertmsg("warning", "ID必须是数字!"); return; } var jsonData = { 'anchorTableId' : anchorTableId, 'anchorName' : anchorName, 'limintStatus' : limintStatus }; $('#grid-table-period').jqGrid('setGridParam', { url : webroot + "interactive/searchAnchorMonitor.htm", postData : jsonData, page : 1, mtype : "post" }).trigger("reloadGrid"); setBtnDisable(e)// set search button disabled and remove the disabled // attribute a few seconds later alert(jsonData); } function resetAnchorMonitor() { $("#anchorTableId").val(""); $("#anthorName").val(""); $("#searchOption").val(""); var jsonData = null; $('#grid-table-period').jqGrid('setGridParam', { url : webroot + "interactive/searchAnchorMonitor.htm", postData : jsonData, page : 1, mtype : "post" }).trigger("reloadGrid"); }; /* 禁播天数的onchange事件 */ function showlimitDay() { var flag = $("#select").val(); if (flag == 1) { $("#limitDay").show(); $("#limitReason").show(); }; if(flag==0){ $("#limitReason").hide(); $("#limitDay").hide(); }; if(flag==2){ $("#limitReason").show(); $("#limitDay").hide(); } }; /* 禁播原因的onchange事件 */ function limitReason() { var flag = $("#select").val(); if (flag == 0) { $("#limitReason").hide(); } else { $("#limitReason").show(); } }; function checkInteger() { var limitTime = $("#limitTime").val(); var reg = /^[1-9]\d*$/; if (reg.test(limitTime)) { } else { alert("天数须是正整数,请重新输入"); $("#limitTime").val(""); return; } }; /* 禁言禁播的二级联动 */ function move() { var s1 = document.getElementById("s1"); var s2 = document.getElementById("s2"); /* <!-- 获取一级和二级的属性--> */ var add; if (s1.value == "0") { add = null; $("#s2").hide(); /* <!--比对value值,实现对应二级text值的动态生成--> */ } else if (s1.value == "1") { $("#s2").show(); add = new Array("1h", "2h", "3h", "5h", "10h"); /* <!--比对value值,实现对应二级text值的动态生成--> */ } else if (s1.value == "2") { $("#s2").show(); add = new Array("1min", "20min", "60min", "180min", "240min"); /* <!--比对value值,实现对应二级text值的动态生成--> */ } s2.length = 0; for (var i = 0; i < add.length; i++) { var ss = new Option(); ss.text = add[i].split()[0]; s2.add(ss); /* <!--把text值添加到二级select中,显示出来--> */ } }
jsJqGrid的更多相关文章
随机推荐
- Android简易实战教程--第十二话《代码获取手机总运行内存的大小》
手机RAM存储,类似于电脑的内存.这一篇,对通过代码获取手机总内存大小做详细介绍. 首先,定义一个engine类,这个类功能就是获取进程信息,包括运行的程序个数,系统总内存,系统剩余总内存.本篇先完成 ...
- 详解EBS接口开发之库事务处理带提前发运通知(ASN)采购接收入库-补充
A) Via ROI Create a ASN [ship,ship] for a quantity =3 on STANDARD PURCHASE ORDER Create via R ...
- 学习TensorFlow,concat连接两个(或多个)通道
深度学习中,我们经常要使用的技术之一,连接连个通道作为下一个网络层的输入,那么在tensorflow怎么来实现呢? 我查看了tensorflow的API,找到了这个函数: tf.concat(conc ...
- Android中JNI编程详解
前几天在参加腾讯模拟考的时候,腾讯出了一道关于JNI的题,具体如下: JNI本身是一个非常复杂的知识,但是其实对于腾讯的这道题而言,如果你懂JNI,那么你可能会觉得这道题非常简单,就相当于C语言中的h ...
- 1082. Read Number in Chinese (25)
题目如下: Given an integer with no more than 9 digits, you are supposed to read it in the traditional Ch ...
- 【一天一道LeetCode】#171. Excel Sheet Column Number
一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处 (一)题目 Given a ...
- React Native移植原生Android
(一)前言 之前已经写过了有关React Native移植原生Android项目的文章,不过因为RN版本更新的原因吧,跟着以前的文章可能会出现一些问题,对于初学者来讲还是会有很多疑难的困惑的,而且官方 ...
- Spring AOP 初探
本文可作为北京尚学堂spring课程的学习笔记 首先谈谈什么是AOP 它能干什么 AOP Aspect Oriented Programming(面向切面的编程) 什么叫面向切面? 就是我们可以动态的 ...
- C语言之统计输入字符数量
这个程序市委了统计所输入的数字或者英文字母的数字的数量,当然稍加改动便可以统计特殊字符的个数,在此不再冗叙. 代码如下: #include <iostream> using namespa ...
- 使用LogKit进行日志操作
1. 概述 任何一个系统中,日志都是不可缺少的,现在Apache提供了两套日志工具,一个就是Log4j,另一个是本文要给出例子的LogKit. Log4j和LogKit有很多相似的地方.比如 ...