mic*_*ele 9 javascript jquery height row jqgrid
我正在使用jqGrid和javascript.我会设置每个表行的高度,但我不明白该怎么做.
这是我的代码:
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);
}
}
);
Run Code Online (Sandbox Code Playgroud)
}
修改RowHeight值行高度不会更改.这是我的表结果

非常感谢.
Ole*_*leg 13
您可以借助setRowData方法设置jqGrid或任何其他CSS属性的各个行的高度(请参阅此Wiki文章).你可以这样做,例如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');
}
});
Run Code Online (Sandbox Code Playgroud)
你可以在这里看到一个有效的例子.在这里你可以看到,在改变行的高度后,最好改变网格的高度.在取消对该行的注释后setGridHeight,结果将如下所示.
更新根据评论中的问题:要更改id ="list"的表格标题的高度,您可以执行以下操作:
$("table.ui-jqgrid-htable", $("#gview_list")).css ("height", 30);
Run Code Online (Sandbox Code Playgroud)
这$("#gview_list")是网格主体和网格标题上的div.
你可以在这里看到结果.
这也有效:
.ui-jqgrid .ui-jqgrid-htable th {
height: 2em !important;
}
.ui-jqgrid tr.jqgrow td{
height: 1em !important;
}
Run Code Online (Sandbox Code Playgroud)