.remove() deletes all table data not just one record
.remove() deletes all table data not just one record
Hi
I have been batling for a few days on this problem.
I have upgraded to DataTables 1.10.4 and editor 1.3.4 and tableTools 2.2.3 libraries and the css files too.
My main reason to move an old application to the new was to use the ssp.class.php functions for my table that are now growing larger.
I have the ssp.class working fine and also I can edit a single record without problems, bt when I use remove() it deletes all records in the table.
// Delete a record (asking user for confirmation)
$('#owner_rentals').on('click', 'a.editor_remove', function (e) {
e.preventDefault();
editor
.title('Delete row')
.message( 'Are you sure you wish to remove this record?' )
.buttons( 'Confirm' )
.remove( $(this).closest('tr')[0] );
} );
Both the edit and remove functions use the same selector $(this).closest('tr')[0]
Also the POST shows the id[] correctly with the single record id number
I cant find any subject on the forum that shows this problem so I gues I am doing something wrong ;-)
Replies
Hi,
In that case it sounds like an error in the server-side script rather than the Javascript code shown above. Are you using the Editor PHP libraries (if so, you don't need ssp.class.php as the Editor libraries have server-side processing support built in), or something else?
Allan
Thanks for the prompt reply
I use ssp.class.php for the DataTables side only, for the editor I use a standard php script that I have been using for DT 1.9 etc.. detailing the data colmuns which I believe I still need as I use british style dates etc...
for the server side script I have used the "simple" one from the link to Github but also found the one that includes the "complex" option which gives me the filtering I need and works fine for the table.
The PHP above is what you use for the editing aspect of the table? It will handle server-side processing itself (example).
Regarding it deleting all rows - I can't see any reason why it would do that!
I would suggest removing
Field::inst( "id" )
asid
is automatically included as the primary key field (controlled by the optional third parameter of the constructor), but aside from that it looks okay.Can you link me to the page in question so I can take a look?
Thanks,
Allan
I will try to place a copy on a public site for you to take a look at.
OK
here is a test table
http://test.lanzarote1.com/progress.php
I have now tried upgrading various tables to 1.10.4 which give me the same results except one which worked after adding idSrc:"id" to the editor. But in this example it makes no difference.
Regards Mark
Hi,
I don't really want to try and delete a row incase I ruin your database! What happens if I do try to? Will it destroy your database?
Allan
Yes it will, but as you can imagine it is just test data.
Please test it but notice the response to the POST , it is empty although the table in the browser still holds the records until you resfresh the page.
Editing instance is setup as follows:
Mark
P,S. I have put a data replenish button on the page so you can retry as many time as you like.
Sorry Allan
It was my fault , I had not placed the new php libraries in the right place and the page was using old version, this obviously caused the problem.
Regards Mark
Phew - good to hear :-). Thanks for the feedback (apologies I missed your reply before).
Allan