您可以使用格式化程序并获取单元格中的最大值/最小值以及该单元格的索引。然后,一旦网格加载完成,您可以使用索引向包含最大/最小数量的行添加一个类。这是解决方案的一个示例:
<script type="text/javascript">
jQuery(document).ready(function(){
var mydata = [
{id:"1",name:"Alex",age:25},
{id:"2",name:"John",age:30},
{id:"3",name:"Peter ",age:29}
];
var currentMaxAmount = 0;
var maxAmountIndex = -1;
var currentIndex = 0;
jQuery("#list4").jqGrid({
datatype: "local",
height: 250,
colModel:[
{name:'name',index:'name', width:100},
{name:'age',index:'age', width:80, align:"right",sorttype:"float", formatter: function (cellvalue, options, rowObject) {
if(parseInt(cellvalue) > currentMaxAmount)
{
currentMaxAmount = parseInt(cellvalue);
maxAmountIndex = currentIndex;
}
currentIndex++;
return cellvalue;
}
}
],
multiselect: true,
data: mydata,
loadComplete: function (gridData) {
if(maxAmountIndex > -1)
$($(".jqgrow")[maxAmountIndex]).addClass("highlighted");
}
});
});
</script>
<style>
tr.highlighted > td{
background-color: red;
}
</style>
希望这会有所帮助。如果您有任何其他问题,请告诉我。