gpt4 book ai didi

javascript - JQgrid设置行高

转载 作者:可可西里 更新时间:2023-11-01 02:56:17 25 4
gpt4 key购买 nike

我正在使用带有 javascript 的 JqGrid。我会设置每个表格行的高度,但我不知道该怎么做。

这是我的代码:

 function jobList(){
var json=doShowAll();
alert("jobList() ==> php/get_job_status.php?value="+json);
jQuery("#jobList").jqGrid({
url:'php/get_job_status.php?value='+json,
datatype: "xml",
colNames:['id','title', 'start', 'stop','completed'],
colModel:[
{name:'id',index:'id', width:15,hidden:true, align:"center"},
{name:'title',index:'title', width:150, align:"center"},
{name:'start',index:'start', width:350, align:"center", sorttype:"date"},
{name:'fine',index:'fine', width:350, align:"center", sorttype:"date"},
{name:'completed',index:'completed', width:120, align:"center",formatter:highlight},//il solitoformatter:infractionInFormatter},
],
//rowNum:8,
//rowList:[8,10,20,30],
pager: '#pagerJobList',
sortname: 'id',
viewrecords: true,
sortorder: "desc",
multiselect: false,
subGrid: false,
autowidth: true,
height: 250,
rowheight: 300,

caption: "Job Progress",
afterInsertRow: function(rowid, aData){
jQuery("#jobList").jqGrid('setCell', rowid, 'completed', '', {
background: 'red',
color: 'white'
});
},
onSelectRow: function(id){
//alert(id);
var title="";
if (id) {
var ret = jQuery("#jobList").jqGrid('getRowData',id);
title=ret.id;
//alert(title);
}
else {
alert("Please select row");
}
var json2=doShowAll();
subGrid(json2,title);
}

}
);

修改 RowHeight 值行高不改变。这是我的表格结果

enter image description here

非常感谢。

最佳答案

您可以在 setRowData 方法的帮助下设置 jqGrid 或任何其他 CSS 属性的各个行的高度(参见 this wiki article )。例如,您可以在 loadComplete 中执行此操作:

$("#list").jqGrid({
// ...
loadComplete: function() {
var grid = $("#list"),
ids = grid.getDataIDs();

for (var i = 0; i < ids.length; i++) {
grid.setRowData(ids[i], false, { height : 20 + (i * 2) });
}

// grid.setGridHeight('auto');
}
});

你可以看到一个working example here .在这里您可以看到,在更改行的高度之后,更改网格的高度可能是个好主意。使用 setGridHeight 取消注释该行后,结果将类似于 this。 .

更新 根据评论中的问题:要使用 id="list" 更改表格标题的高度,您可以执行以下操作:

$("table.ui-jqgrid-htable", $("#gview_list")).css ("height", 30);

$("#gview_list") 是网格主体和网格标题上的一个 div。

可以看到结果here .

关于javascript - JQgrid设置行高,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3203402/

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