我试图在jqgrid plugin中使用tabletogrid函数。我的问题是,如果我删除表中的一行,那么表格单元的width属性就会消失。但是,如果最后一行被删除,则删除操作按预期发生。 例如,这里是我的HTML表格 -jqGrid TableToGrid删除一行
<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']
});
删除操作会导致width属性消失。这是为什么发生?
网格细胞得到显示的是这样的...
<TD style="WIDTH: 80px" title="" role=gridcell><DIV class=shop></DIV></TD>
如果删除除最后一行的任何行,变成这样的细胞....
<TD title="" role=gridcell><DIV class=shop></DIV></TD>
宽度属性被删除。我在这里错过了什么?