gpt4 book ai didi

jquery - jqgrid奇偶行颜色

转载 作者:行者123 更新时间:2023-12-01 07:13:49 25 4
gpt4 key购买 nike

当我应用样式类myAltRowClass来更改jqgrid奇偶行的备用颜色时。左、右、下边框均为黑色。

我想通过css所有jqgrids应用奇偶行颜色

网格如下图所示

oddevenproblem

loadComplete 函数中使用以下代码时,不会出现此问题

$("tr.jqgrow:odd").css("background", "#E0E0E0");

jqgrid 如下图所示

oddevenrow

CSS 类

.myAltRowClass {
background: #E0E0E0;
}

代码:

$(document).ready(function(){
//jqGrid
$("#usersList").jqGrid({
url:'<%=request.getContextPath() %>/Admin/getAllUsersList',
datatype: "json",
colNames:['Edit','First Name','Middle Name','LastName','Mobile Number','Active'],
colModel:[
{name:'userId',search:false,index:'userId',width:30,sortable: false,formatter: editLink},
{name:'firstName',index:'firstName', width:100},
{name:'middleName',index:'middleName', width:100},
{name:'lastName',index:'lastName', width:100},
{name:'mobileNo',index:'user.mobileNo', width:100},
{name:'isActive',index:'user.isActive',width:80},
],
rowNum:20,
rowList:[10,20,30,40,50],
rownumbers: true,
pager: '#pagerDiv',
sortname: 'user.primaryEmail',
viewrecords: true,
sortorder: "asc",

loadComplete: function() {
//$("tr.jqgrow:odd").css("background", "#E0E0E0");

$("tr.jqgrow:odd").addClass('myAltRowClass');
},

});
$('#gridContainer div:not(.ui-jqgrid-titlebar)').width("100%");
$('.ui-jqgrid-bdiv').css('height', window.innerHeight * .65);
$('#load_usersList').width("130");
$("#usersList").jqGrid('navGrid','#pagerDiv',{edit:false,add:false,del:false},{},{},{}, {closeAfterSearch:true});
$(".inline").colorbox({inline:true, width:"20%"});
});

function editLink(cellValue, options, rowdata, action)
{
return "<a href='<%=request.getContextPath()%>/Admin/editUser/" + rowdata.userId + "' class='ui-icon ui-icon-pencil' ></a>";
}

最佳答案

The demo演示如何定义 CSS 规则并将规则设置为网格的奇数行和偶数行。演示中使用的代码

loadComplete: function () {
$(this).find(">tbody>tr.jqgrow:odd").addClass("myAltRowClassEven");
$(this).find(">tbody>tr.jqgrow:even").addClass("myAltRowClassOdd");
}

了解 jqGrid 使用网格中的第一个隐藏行来设置列宽非常重要。所以必须使用 jQuery :even选择器在奇数行上设置类,并且必须使用 :odd选择器在偶数行上设置类。

我在演示中使用的 CSS 规则如下

.myAltRowClassEven { background: #E0E0E0; border-color: #79B7E7; color: Tomato; }
.myAltRowClassOdd { background: DarkOrange; }
.ui-state-hover.myAltRowClassEven { color: Magenta; }
.ui-state-hover.myAltRowClassOdd { color: RoyalBlue; }
.ui-state-highlight.myAltRowClassEven { color: PaleGreen; }
.ui-state-highlight.myAltRowClassOdd { color: Sienna; }

结果,我们得到了非常多彩的图片,例如奇数/偶数/悬停/选定行具有不同的颜色或背景颜色:

enter image description here

颜色看起来很糟糕。我只是想演示如何在那里进行自定义。

关于jquery - jqgrid奇偶行颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21906215/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com