Remove rows: button or icon "onclick" remove all rows with the same value
Remove rows: button or icon "onclick" remove all rows with the same value
charallave
Posts: 6Questions: 1Answers: 0
in Buttons
Hi,
I have a datatable with 100 million rows with columns: "url" (300.000 values) and "file" (100 million of values). I need a button or icon per row. On click removes all the rows with the same "url" value. Thanks!
Answers
Given the number of rows, this would be server-side processing, so you'll need a script on the back-end that would delete the records out of the database. You could use
columns.render
to put the button on the row, see example here.Colin
Thank you!
But... I don't want to delete the data in the server database, I just want to remove (or hide) the rows in the table.
With
serverSide
, the data always comes from the server, so if you want the row removed, you'll need to remove it on the server itself. If you don't, the remove won't persist - as soon as you search, order or change page, that row will come back. You could keep an array of rows that have been removed, then on everydraw
see if those rows are present and remove them withrow().remove()
, but it'll get messy because pages will have odd lengths, and any page refresh would bring all those rows back again regardless.Colin
Thanks again!
And what about rows().remove()?
Does it also delete the data on the server?
The
row().remove()
API works with client side processing only. If you are using server side processing, as Colin suggests, then this API won't work. You could useajax.data
as a function to send information to the server of what rows to filter in the the response. See this example.Kevin
In addition to Kevin's comment,
rows().remove()
behaves similarly torow().remove()
- it just allows you to remove multiple rows at the same time.Colin
Thank you.
On the other hand, I have a table with millions of records searching with wilcards which is very slow. I'm testing sphinx to speed up searches. Is it possible to use php + datatables + sphinx?
I'm not familiar with Sphinx, but provided it can respond with the information expected by DataTables, it should be fine. The protocol is discussed here. Also see examples here.
Cheers,
Colin
Hi,
I have half the solution, i would need to solve the other half ... :-)
I have created an index.php with SQL SELECT using wildcards to a Sphinx service that returns a list (array) with all the IDs that I need to do (in ajaxfile.php) the query select * from table where value IN ($ myids). How do I send that list to ajaxfile.php?.
Thanks!
Do you mean that in
index.php
where your DataTables Javascript is being run, you have a list of ids which you want to send to the server (ajaxfile.php
) and use that as the basis for your SQL query in that file?If so, you can send extra information to the server using
ajax.data
.Allan
You're right!
It works correctly like this:
<
script>
$(document).ready(function(){
$('#empTable').DataTable({
'searchDelay': 1500,
'processing': true,
'serverSide': true,
'deferRender': true,
'serverMethod': 'post',
'ajax': {
'url':'ajaxfile3.php',
"data": {"myids": ('70, 40,50 ')
}
},
but it doesn't work when I try:
"data": function (d) {
"myids": ('$ myids')
} ...
Is it a syntax problem?
Thank you!