我試圖在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>
寬度屬性被刪除。我在這裏錯過了什麼?