jqgrid 突出显示第 1 页中的 maximum/minimum 单元格值
jqgrid highlight maximum/minimum cell value from 1 page
jqgrid 可以突出显示 1 页中的 maximum/minimum 单元格值吗?
例如
Name | Age
Alex | 25
John | 30 ----> Highlight this row
Peter | 29
page 1 > >>
感谢您的帮助,
此致,
埃卡
您可以使用格式化程序并获取单元格中的 maximum/minimum 值和该单元格的索引。然后,一旦网格加载完成,您可以使用索引将 class 添加到包含 maximum/minimum 数量的行。这是解决方案的示例:
<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>
希望这对您有所帮助。如果您还有其他问题,请告诉我。
jqgrid 可以突出显示 1 页中的 maximum/minimum 单元格值吗?
例如
Name | Age
Alex | 25
John | 30 ----> Highlight this row
Peter | 29
page 1 > >>
感谢您的帮助,
此致,
埃卡
您可以使用格式化程序并获取单元格中的 maximum/minimum 值和该单元格的索引。然后,一旦网格加载完成,您可以使用索引将 class 添加到包含 maximum/minimum 数量的行。这是解决方案的示例:
<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>
希望这对您有所帮助。如果您还有其他问题,请告诉我。