【发布时间】:2012-11-23 08:06:40
【问题描述】:
我正在尝试在jqgrid plugin 中使用 tabletogrid 函数。我的问题是,如果我删除表格中的一行,那么表格单元格的宽度属性就会消失。但是如果最后一行被删除,那么删除操作会按预期发生。 例如,这是我的 html 表 -
<table id="item_table">
<thead>
<tr>
<th width="60">Date</th>
<th width="15">Icon</th>
<th width="80">Shop</th>
<th width="15">Delete</th>
</tr>
<thead>
<tbody>
<tr>
<td width="60" class="col_date">
<div class="date"></div>
</td>
<td width="15" class="col_icon">
<div class="icon"></div>
</td>
<td width="80" class="col_shop">
<div class="shop"></div>
</td>
<td width="25" class="col_delete">
<div class="delete"></div>
</td>
</tr>
</tbody>
</table>
然后我使用 ajax 代码将内容添加到表中。之后,这是我的 jqgrid 设置。
jQuery.extend(jQuery.jgrid.defaults, {
caption: "Shops",
autowidth: true,
height: 24,
hidegrid: false,
onCellSelect: function(rowid, index, contents, target) {
if (index == 3) {
$('#item_table tr:eq(' + rowid + ')').remove();
}
},
colModel:[
{ name: 'date', index: 'date', width: 0, resizable: false },
{ name: 'icon', index: 'icon', width: 0, resizable: false },
{ name: 'shop', index: 'shop', width: 0, resizable: false },
{ name: 'delete', index: 'delete', width: 0, resizable: false }
]
});
tableToGrid("#item_table", {
colNames: ['Date', '', 'Shop', 'Delete']
});
删除操作导致宽度属性消失。为什么会这样?
网格中的单元格会像这样显示...
<TD style="WIDTH: 80px" title="" role=gridcell><DIV class=shop></DIV></TD>
如果删除除最后一行之外的任何一行,单元格就会变成这样......
<TD title="" role=gridcell><DIV class=shop></DIV></TD>
Width 属性被移除。我在这里错过了什么?
【问题讨论】: