Restore deleted rows button?
Restore deleted rows button?
Hi!
Is there any option to restore/show back deleted rows by button click without reloading page?
Here is my example:
http://live.datatables.net/buhiseti/6/
I was trying to use this code example:
https://stackoverflow.com/questions/30086341/datatable-hide-and-show-rows-based-on-a-button-click-event
for "restore deleted" button but it's not working here.
I was thinking about adding "visibility: hidden" to selected rows after "delete selected" button click
and add "toggle visibility" function to "restore deleted" button but I dont know how to connect it with "selected" rows.
Anyone can help me out?
Thanks
Replies
The problem with your code is that .remove permanently removes the row. It does not just hide it.
Here is one possible solution: http://live.datatables.net/seyetoje/1/edit
The thing that I don't like about my solution is that when inverted, it is showing them selected. I would consider adding and removing a different class name with the selected and deselected event handlers to solve that problem.
@bindrid
Can You help me out with that?
Invert selected button is really important for me
http://live.datatables.net/seyetoje/7/edit is a little more to my liking
It uses it own class to track deleted instead of the "selected" class
Now It's totally unpractal, there is no solution for these 3 buttons working at the same time?
"DELETE SELECTED"
"RESTORE DELETED"
"INVERT SELECTION"
You can change the button text to what ever you want. This does what you asked for.
The filter looks for the class "deleted" and acts accordingly.
Button 1 adds the deleted class to the selected rows causing them to be removed from the user's view.
Button 2 changes the filter to show only rows that have the deleted class
Button 3 removes the "deleted" class causing the rows to come into view of the user again.
In my production code, I do not hide any rows. I toggle the background color. That way, they can see what rows are marked for delete. Then when they hit the save changes button, I use ajax to notify the server what rows should be permanently removed.
This code is straight forward so you should be able to analyze it and change it to your liking.
"Button 3 removes the "deleted" class causing the rows to come into view of the user again."
In Your last example? not.
Check it by yourself.
I just need working "hide deleted" and "show deleted back" buttons.
Button 3 does work but first you need to show deleted (Button 2) and select the rows you want to undelete. Then click Button 3.
Like Bindrid said you can modify the code to meet your needs.
Kevin