I am trying to use tabletogrid function in jqgrid plugin . My problem is that if I delete a row in the table, then the width attribute of the cells in the table just disappears. But if the last line is deleted, the delete operation is performed as expected. For example, here is my html table -
<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>
Then I add the content to the table using ajax code. After that, here is my jqgrid setup.
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']
});
The delete action causes the width attribute to disappear. Why is this happening?
Grid cells are displayed like this:
<TD style="WIDTH: 80px" title="" role=gridcell><DIV class=shop></DIV></TD>
If any row except the last row is deleted, the cells become like this ...
<TD title="" role=gridcell><DIV class=shop></DIV></TD>
The width attribute is removed. What am I missing here?