I have attached the code I am using. I have added a trash can icon to both the toolbar and each row to try different methods. I add several rows and then press an earlier row (while still in edit mode) and both trash cans work, the row is removed. Then I can select any row (not in edit mode but highlighted) and when I press the trash can icon, the destroy message is displayed but the row is not destroyed. If I double click any row (to re-enter edit mode) and then either trash can icon, the row is removed. Also, in all cases, I don't see the alert message I set for the on Destroy event. It is not firing.
<!-- Datagrid -->
<div id="itemBar" style="padding:5px;height:auto">
<div>
<img name="newItem" src="themes/default/icons/16x16/actions/list-add.png" type="img" height="16" id="newItem" onclick="$('#item_main').edatagrid('addRow');" style="cursor:pointer" title="Add" />
<img name="removeItem" src="themes/default/icons/16x16/places/user-trash.png" type="img" height="16" id="removeItem" onclick="alert('toolbar destroyRow'); $('#item_main').edatagrid('destroyRow');" style="cursor:pointer" title="Trash" />
</div>
</div>
<script type="text/javascript">
function item_mainFormatter(value, row, index) {
var text = '<img type="img" src="themes/default/icons/16x16/places/user-trash.png" height="16" onclick="$(\'#item_main\').edatagrid(\'destroyRow\');" style="cursor:pointer" title="Delete" /> ';
return text;
}
</script>
<div style="clear:both">
<table title="" toolbar="#itemBar" fitColumns="true" idField="id" singleSelect="true" name="item_main" id="item_main" class="easyui-datagrid">
<thead>
<tr>
<th hidden="true" editor="text" field="id"></th>
<th width="50" formatter="item_mainFormatter" align="center" field="action">Action</th>
<th width="40" editor="{type:'numberbox',options:{precision:4}}" resizable="true" align="center" field="qty">Quantity</th>
<th width="80" sortable="true" resizable="true" align="center" editor="{type:'combogrid',options:{onShowPanel:function(){ itemInit(this, 'none'); }}}" field="sku">SKU</th>
<th width="160" editor="text" resizable="true" field="description">Description</th>
<th width="60" editor="text" resizable="true" align="right" field="price">Price</th>
<th width="80" editor="text" resizable="true" align="right" field="total" style="text-align:right">Total</th>
</tr>
</thead>
</table>
</div>
<script type="text/javascript">
$('#item_main').edatagrid({
onDestroy:function(rowIndex, row) { alert('onDestroy row'); },
onAdd:function(rowIndex, row) { alert('onAdd row'); lastIndex=rowIndex; rowAutoAdd=true; },
onEdit:function(rowIndex, row) { alert('onEdit row'); lastIndex=rowIndex; }
});
</script>
Ultimately, I would like to be able to press the trash can icon on a given row (no matter is it is selected or not), have it selected and then destroyed followed by a function to total the remaining rows.
Thanks for your help on this one. I'm pulling out what little hair I have left trying to get this to work.
Dave