jqgrid表格内状态条

效果图

 

css部分

<style>
.ztb_main_01 li{list-style:none;display:inline-block}-->
.online{width:38px;height: 2px; position:relative; left: 8px;right: 0px;top:9px;bottom: 0px;overflow: hidden; border-bottom:5px solid #ccc; z-index:-1}
.ztb_main_01{ position:relative; z-index:1000;display: block;height: 80px}
.ztb_content_01{z-index:1000;height: 40px;margin-left: 5px;display: block}
.font{height: 40px;font-size: 12px;margin-left:0px;display: block}
.font li{margin-left: 0px;width:40px;display: inline-block;vertical-align: middle;}
.circle{font-size:14px; color:#404040; background:url(../res/images/ztb_lc.png) no-repeat;padding-left:15px; height:24px;width:40px}
.circleSelect{font-size:14px; background:url(../res/images/circleselect.png) no-repeat;padding-left:16px; height:26px;width:42px;margin-left: 0px}
.ztb_content_01 li:last-child div{width:0px;}
</style>

html部分
<div class="padding20 bgWhite marginTop20">
<div class="cus-grid row" id="grid-wrap">
<div class="col-lg-12">
<table id="list2"></table>
<div id="pager2"></div>
</div>
</div>
</div>

js部分
<script type="text/javascript">

var str = [{"id": "1","name": "&nbsp;草稿<br>(暂存)"},
{"id": "2","name": "&nbsp;&nbsp;草稿<br>(已验证)"},
{"id": "3","name": "运行中"},
{"id": "4","name": "已下线"}];

$(function(){
pageInit();
});


function pageInit(){
//创建jqGrid组件
jQuery("#list2").jqGrid(
{
url : '../configCenter/json/scene.json',
datatype : "json",//请求数据返回的类型。可选json,xml,txt
height:'auto',
colNames : ['id','场景名称', '场景描述', '场景状态', '创建时间', '修改时间', '修改人','操作'],//jqGrid的列显示名字
colModel : [ //jqGrid每一列的配置信息。包括名字,索引,宽度,对齐方式.....
{name: 'id', key: true, hidden:true},
{name : 'scenename',index : 'name',editable : false,editoptions : {readonly : true,size : 10},align:"left"},
{name : 'desc', width: 110,index : 'filesize',editable : true,editoptions : {size : 10},align:"left"},
{name : 'status', width: 180,index : 'people',editable : true,editoptions : {size : 10},align:"left",
formatter: function (cellvalue, options, rowObject) {

return init(str,1);

}
},
{name : 'time',index : 'date',editable : true,editoptions : {size : 10},align:"left"},
{name : 'updatetime',index : 'date',editable : true,editoptions : {size : 10},align:"left"},
{name : 'updateman',index : 'date',editable : true,editoptions : {size : 10},align:"left"},
{name : 'handle',index : 'handle',editable : true,editoptions : {size : 10},align:"left",
formatter: formatContext
}

],

shrinkToFit:true,
rowNum : 10,//一页显示多少条
rowList : [ 10,40],//可供用户选择一页显示多少条
pager : '#pager2',//表格页脚的占位符(一般是div)的id
sortname : 'id',//初始化的时候排序的字段
sortorder : "desc",//排序方式,可选desc,asc
mtype : "GET",//向后台请求数据的ajax的类型。可选post,get
viewrecords : false,
caption : "",//表格的标题名字,
multiselect: true,//表格的多选设置,全部勾选已经内部配置;
editurl : 'data/JSONData.json',
autowidth:true,
altRows:true,
}
);
}
//创建layer弹幕层
//格式化表格
//
function formatContext( cellvalue, options, rowObject ){
var id = options.rowId;
return '<span class="handle" οnclick="see(this)">查看</span><span class="handle" οnclick="edit(this)">编辑</span><span class="handle" οnclick="deleteApply(this)">删除</span><span class="handle" οnclick="stop(this)">停用</span>';
//return '<a href=\'committee-apply-add.html\' target="_blank" style=\'color: blue;text-decoration:underline\'>修改</a> <a href=\'confirm.html\' target="_blank" style=\'color: blue;text-decoration:underline\'>申请</a> <a ds_id="\'+ds_id+\'" οnclick="deleteApply(this)" flag=\'"+id+"\' style=\'color: blue;text-decoration:underline\'>删除</a> <a href=\'reviewlayer.html\' target="_blank" style=\'color: blue;text-decoration:underline\'>撤回</a>';
}

function init(data,id) {
html="";
html += '<div class="ztb_main_01">'+
'<ul class="ztb_content_01">';
$.each(data,function(a){
if(data[a].id==id){
html += '<li class="circleSelect"><div class="online" style="margin-left: 1px"></div></li>'
}else{
html += '<li class="circle"><div class="online"></div></li>'
}
});
html += '</ul>'+
'<ul class="font">';
$.each(data,function(b){
html+='<li>'+data[b].name+'</li>';
});
html += '</ul></div>';
return html;
}
</script>


 

 

转载于:https://www.cnblogs.com/required/p/10429738.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
可以通过以下步骤设置 jqGrid 表格样式: 1. 引入 jqGrid 插件和样式文件。 ``` <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqgrid/5.4.0/css/ui.jqgrid.min.css" /> <script src="https://cdnjs.cloudflare.com/ajax/libs/jqgrid/5.4.0/js/jquery.jqgrid.min.js"></script> ``` 2. 在 HTML 页面中添加一个 div 元素作为表格容器。 ``` <div id="grid"></div> ``` 3. 使用 JavaScript 代码初始化 jqGrid 表格并设置样式。 ``` $(function(){ $("#grid").jqGrid({ url: "data.json", datatype: "json", colModel: [ { name: "id", label: "ID", width: 50 }, { name: "name", label: "Name", width: 150 }, { name: "age", label: "Age", width: 50 }, { name: "address", label: "Address", width: 200 } ], rowNum: 10, rowList: [10, 20, 30], pager: "#pager", sortname: "id", viewrecords: true, sortorder: "asc", caption: "Sample Grid" }); $("#grid").jqGrid("navGrid", "#pager", { edit: false, add: false, del: false }); }); ``` 4. 在 CSS 文件中添加样式。 ``` .ui-jqgrid { font-size: 14px; } .ui-jqgrid tr.jqgrow td { padding: 5px; } .ui-jqgrid .ui-jqgrid-hdiv { background-color: #f2f2f2; } .ui-jqgrid .ui-jqgrid-btable { border-collapse: separate; border-spacing: 0px; } .ui-jqgrid .ui-jqgrid-pager { background-color: #f2f2f2; border-top: none; } .ui-jqgrid .ui-jqgrid-pager .ui-pg-table { margin: 0; } .ui-jqgrid .ui-jqgrid-pager .ui-pg-table .ui-pg-button { border: none; margin: 0 5px; } .ui-jqgrid .ui-jqgrid-pager .ui-pg-table .ui-pg-button:hover { background-color: #e6e6e6; } ``` 注意:样式文件中的样式可以根据需要进行修改,以上只是一个示例。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值