jqGrid设置指定行的背景色
1.在页面中加样式
<style type="text/css">
.SelectBG{
background-color:#AAAAAA;
}
</style>
2.在js中
gridComplete:function(){
var ids = $("#gridTable").getDataIDs();
for(var i=0;i<ids.length;i++){
var rowData = $("#gridTable").getRowData(ids[i]);
if(rowData.overdueDays==0){//如果天数等于0,则背景色置灰显示
$('#'+ids[i]).find("td").addClass("SelectBG");
}
}
}
案例:
shrinkToFit: true,//此属性用来说明当初始化列宽度时候的计算类型,如果为ture,则按比例初始化列宽度。如果为false,则列宽度使用colModel指定的宽度
multiselect: true, multiboxonly: true,//只有当multiselect = true.起作用,当multiboxonly 为ture时只有选择checkbox才会起作用
gridComplete: function () {
var ids = $("#gridTable").getDataIDs();
for (var i = 0; i < ids.length; i++) {
var rowData = $("#gridTable").getRowData(ids[i]);
if (rowData.Audit == "不通过") {//如果审核不通过,则背景色置于红色
$('#' + ids[i]).find("td").addClass("SelectBG");
}
}
$("#" + this.id).jqGrid('setSelection', SelectRowIndx);
}
//加载表格
function GetGrid() {
var SelectRowIndx;
$("#gridTable").jqGrid({
url: "@Url.Content("~/School/SitesDetails/GridPageListJson")",
datatype: "json",
height: $(window).height() - 178,
autowidth: true,
colModel: [
{ label: '主键', name: 'Id', index: "Id", hidden: true, key: true,},
{ label: '所属栏目', name: 'Name', index: "Name", width: 100 },
{ label: '标题名称', name: 'Title', index: "Title", width: 320 },
//{label:'文章来源',name:'origin',index:'origin',width:100},
{
label: '置顶', name: 'IsTop', index: 'IsTop', width: 80
,
formatter: function (cellvalue, options, rowObject) {
if (cellvalue == true) return "是";
if (cellvalue == false) return "否";
}
},
{ label: '点击量', name: 'Hits', index: 'Hits', width: 80 },
{
label: '允许评论', name: 'IsComment', index: 'IsComment', width: 80
,
formatter: function (cellvalue, options, rowObject) {
if (cellvalue == true) return "是";
if (cellvalue == false) return "否";
}
},
{
label: '审核', name: 'Audit', index: 'Audit', width: 80
,
formatter: function (cellvalue, options, rowObject) {
if (cellvalue == "1") return "<font color='blue'>等待审核</font>";
if (cellvalue == "2") return "<font color='green'>通过审核</font>";
//if (cellvalue == "3") return "<font color='red'>不通过</font>";
if (cellvalue == "3") return "不通过";
}
},
{ label: '文章标签', name: 'ArticleFlag', index: 'ArticleFlag', width: 80 },
{ label: '创建者', name: 'CreateUserName', index: 'CreateUserName', width: 80 },
{
label: '创建日期', name: 'CreateDate', index: 'CreateDate', width: 120,
formatter: function (cellvalue, options, rowObject) {
return formatDate(cellvalue, 'yyyy-MM-dd hh:mm');
}
},
{ label: '修改者', name: 'ModifyUserName', index: 'ModifyUserName', width: 80 },
{
label: '修改日期', name: 'ModifyDate', index: 'ModifyDate', width: 120,
formatter: function (cellvalue, options, rowObject) {
return formatDate(cellvalue, 'yyyy-MM-dd hh:mm');
}
},
{ label: '审核人', name: 'AuditUserName', index: 'AuditUserName', width: 80 },
{
label: '审核日期', name: 'AuditDate', index: 'AuditDate', width: 120,
formatter: function (cellvalue, options, rowObject) {
return formatDate(cellvalue, 'yyyy-MM-dd hh:mm');
}
}
],
viewrecords: true,
rowNum: 30,
rowList: [30, 50, 100, 500, 1000],
pager: "#gridPager",
sortname: 'CreateDate',
sortorder: 'Desc',
rownumbers: true,
shrinkToFit: true,//此属性用来说明当初始化列宽度时候的计算类型,如果为ture,则按比例初始化列宽度。如果为false,则列宽度使用colModel指定的宽度
multiselect: true,
multiboxonly: true,//只有当multiselect = true.起作用,当multiboxonly 为ture时只有选择checkbox才会起作用
ondblClickRow: function (rowid) {
var KeyValue = rowid;
if (IsChecked(KeyValue)) {
var url = "/School/SitesDetails/Form?KeyValue=" + KeyValue;
openDialog(url, "Form", "编辑文章", 900, 450, function (iframe) {
top.frames[iframe].AcceptClick();
});
}
},
onSelectRow: function () {
SelectRowIndx = GetJqGridRowIndx("#" + this.id);
},
gridComplete: function () {
var ids = $("#gridTable").getDataIDs();
for (var i = 0; i < ids.length; i++) {
var rowData = $("#gridTable").getRowData(ids[i]);
if (rowData.Audit == "不通过") {//如果审核不通过,则背景色置于红色
$('#' + ids[i]).find("td").addClass("SelectBG");
}
} $("#" + this.id).jqGrid('setSelection', SelectRowIndx);
}
});
columnModelData("#gridTable");
//自应高度
$(window).resize(function () {
$("#gridTable").setGridHeight($(window).height() - 178);
});
}
效果图如下:

jqGrid设置指定行的背景色的更多相关文章
- 原创:如何实现在Excel通过循环语句设置指定行的格式
原创:如何实现在Excel通过循环语句设置指定行的格式 一.需求: 想让excel的某些行(比如3的倍数的行)字体变成5号字 如何整: 二.实现: Sub code() To Range(" ...
- DevExpress.XtraGrid.Views 设置指定行的背景颜色 .
如需要将指定行的背景设置颜色,可参考以下示例 1.事件:CustomDrawCell 2.示例: private void gridView1_CustomDrawCell(object sender ...
- 使用layui框架根据字段来设置tr行的背景色
问题来源:最近在写公司项目时使用layui遇见的问题,老板要求根据td字段来设置整行tr的背景色. 解决:一开始数据比较少的时候只是直接在页面根据js动态判断字段然后来更改背景色,结果能够成功,但是后 ...
- JQuery EasyUI DataGrid根据条件设置表格行样式(背景色)
1.javascript定义函数返回样式 <script type="text/javascript"> //根据条件设置表格行背景颜色 function setRow ...
- 设置datalist指定行的背景色
前台: <div class="table-responsive" > <table class="table table-bordered table ...
- jqgrid 设置编辑行中的某列为下拉选择项
有时,需要对编辑行中的某列的内容通过选择来完成,以保证数据的一致性.规范性. 可设置colModel的label的属性 edittype: "select",同时指定 editop ...
- Android Material适配 为控件设置指定背景色和点击波纹效果
Android Material适配 为控件设置指定背景色和点击波纹效果,有需要的朋友可以参考下. 大部分时候,我们都需要为控件设置指定背景色和点击效果 4.x以下可以使用selector,5.0以上 ...
- WPF ListView控件设置奇偶行背景色交替变换以及ListViewItem鼠标悬停动画
原文:WPF ListView控件设置奇偶行背景色交替变换以及ListViewItem鼠标悬停动画 利用WPF的ListView控件实现类似于Winform中DataGrid行背景色交替变换的效果,同 ...
- 设置listContrl中指定行的颜色
在MFC中 自己通过手动拖放CListCtrl控件来制作自己的表格: 目的: 将指定item的行更该颜色: 步骤: 1,在窗口中拖放CListCtrl控件, 单击右键 创建控件对象: CListCtr ...
随机推荐
- 创建DOTA2本地数据库(一)
在APP中,用本地数据库好于频繁的联网去获取相关数据.我使用SQLite作为本地的数据库,比较轻巧. 英雄 首先先建立英雄的数据库,暂时我先只设置ID,name,loaclized_name这三种,我 ...
- 虚拟机和windows主机中的文件共享
22:54 2015/12/22 虚拟机和windows主机中的文件共享:特别推荐:我的一个老师特别推荐的方法:在windows安装SSH Secure File Transfer Client,直接 ...
- 【BZOJ】3922: Karin的弹幕
题意 给定一个长度为\(n(1 \le n \le 70000)\)序列,\(m(1 \le m \le 70000)\)次操作:1. 对一段下标是等差数列的子序列求最大值:2. 单点修改. 分析 如 ...
- CSS清除浮动八种方法
在各种浏览器中显示效果也有可能不相同,这样让清除浮动更难了,下面总结8种清除浮动的方法,测试已通过 ie chrome firefox opera,需要的朋友可以参考下 清除浮动是每一个 web前台设 ...
- CSS3初学篇章_7(布局/浏览器默认样式重置)
CSS布局说到布局,就不得不提布局的核心<div>标签,它与其它标签一样,也是一个XHTML所支持的标签,专门用于布局设计的容器标签.在css布局方式中,div 是这种布局方式的核心对象, ...
- session在本地可以正常使用,而在sae上却无法使用或者值为空的解决方法
session在本地可以正常使用,而在sae上却无法使用或者值为空的解决方法: session_start()放在当前页代码的第一行即可解决该问题. 在本地上session_start()如果不是放在 ...
- 配置apache虚拟域名
Apache配置文件的修改. ----> Apache-----> httpd.conf,打开httpd.conf文件. 1)找到:#LoadModule rewrite_modu ...
- JsonTest
以前用MVC写网站时并不用考虑Json的转换,MVC已经提供了现成的方法. 现在没有用MVC,我就在考虑如何自己转换Json,想来想去自己写还是不够完美,于是尝试了一些其他人写的方法,尝试过微软提供的 ...
- SQL Server获取自增列下一个Id
IDENT_CURRENT('TableName')为当前的最大标识值,IDENT_INCR('TableName')为设置的标识值增量, 两者相加即为下一个标识值 SELECT IDENT_CURR ...
- fenye
<div class="ptb20 navpages"> <span class=" ">共有<span class=" ...