EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: arma on November 11, 2015, 03:46:37 AM



Title: Remove Grid Row
Post by: arma on November 11, 2015, 03:46:37 AM
Hi,

What is the best way to remove grid row while in cell editing mode? I could find it the information here http://www.jeasyui.com/extension/datagrid_cellediting.php (http://www.jeasyui.com/extension/datagrid_cellediting.php)

Thanks.


Title: Re: Remove Grid Row
Post by: stworthy on November 11, 2015, 08:13:34 AM
You can call 'deleteRow' method to delete a row. If this row is in editing mode, please call 'cancelEdit' method to end the editing and then call 'deleteRow' method to delete it.
Code:
$('#dg').datagrid('cancelEdit', index);
$('#dg').datagrid('deleteRow', index);


Title: Re: Remove Grid Row
Post by: arma on November 11, 2015, 04:18:41 PM
Thanks stworthy,

I have now another issue:

1. Load grid with some data and call the grid enableCellEditing
2. I then empty the grid and insertRow with index 0.
3. After i click cell and edit a field, the grid become frozen.

Do you have any clue to solve this?


Title: Re: Remove Grid Row
Post by: stworthy on November 11, 2015, 07:23:58 PM
Please refer to http://jsfiddle.net/jw0y2p54/. It works fine.


Title: Re: Remove Grid Row
Post by: arma on November 12, 2015, 03:48:06 AM
Awesome  ;D thank you.


Title: Re: Remove Grid Row
Post by: arma on January 02, 2016, 03:49:24 PM
Hi Stworthy,

It looks like calling getSelected on editable cell grid return null, so that i could not get the selected row index.
It even does not trigger onSelect row method. Is it considered as a bug ?

Please check the js fiddle link here. http://jsfiddle.net/72m654kg/1/
 (http://jsfiddle.net/72m654kg/1/)

My workaround at the moment is to maintain global variable to store the selected row from ClickRow even and later get the index from that variable.

Code:
var selectedRow = null;
...
onClickRow: function(index, row){
     selectedRow = row;
}
...
//I user selectedRow to get index to use as deleteRow parameter.


Title: Re: Remove Grid Row
Post by: stworthy on January 02, 2016, 06:20:06 PM
When you enable cell editing on a datagrid, you can not select a whole row but only one cell at a time. Please call 'cell' method to get the selected cell index and field name.

http://jsfiddle.net/72m654kg/4/


Title: Re: Remove Grid Row
Post by: arma on January 02, 2016, 06:28:23 PM
Thanks a lot, your solution is much simpler :D