EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: jherrera on July 24, 2013, 04:46:27 AM



Title: Deleting rows in a grid with multiple IDs
Post by: jherrera on July 24, 2013, 04:46:27 AM
Hi,

I've some grids where I have more than one ID field. For example, one of my grids has a column called order_id and another one called order_item_id (both fields are part of the PK of my order_items table in the backend). The values for those two columns must be sent to the server when I want to delete a row but, in the standard grid definition, I can only use one field as "idField".

Which is the best way to handle row deletions on tables where there's more than one idField?

Thanks in advance.


Title: Re: Deleting rows in a grid with multiple IDs
Post by: stworthy on July 24, 2013, 07:53:27 AM
Get a specified row and you will be able to post any fields to server. The code below shows how to delete the selected row.
Code:
var row = $('#dg').datagrid('getSelected');
if (row){
$.post(url, {
order_id: row.order_id,
order_item_id: row.order_item_id
}, function(){
$('#dg').datagrid('reload');
});
}


Title: Re: Deleting rows in a grid with multiple IDs
Post by: jherrera on July 25, 2013, 07:25:24 AM
Thanks! It worked like a charm.