actualizar datatable cada x sgundos
actualizar datatable cada x sgundos
diegorivas45
Posts: 3Questions: 0Answers: 0
alguien que me ayude como puedo actualizar una datatable automaticamente sin usar ajax lo que intento es que segun el valor del dato de una consulta sql cambie el color de la celda pero solo para esa fila gracias no estoy usando el metodo ajax
This discussion has been closed.
Replies
if you just want to change the color of a row based on the result of an SQL query you can use $.fn.dataTable.ext.search.push, find the rows whose color you would like to change, change the color and return "true".
$.fn.dataTable.ext.search.push gets triggered on table draw. Use this command to redraw the table: https://datatables.net/reference/api/draw()
This is one way to use search.push: https://datatables.net/examples/plug-ins/range_filtering.html
And here is another one that allows you to get hold of individual rows:
https://datatables.net/forums/discussion/45637/possible-to-have-search-filters-away-from-table#latest
lo que intento hacer que que cada vez que se haga un cambio en la base de datos se actualice automáticamente la tabla
y quiero que cada x segundos consulte de nuevo y actualice los datos
since your are not using ajax I cannot really help you very much I am afraid. But one thing is clear to me: After sending the data from the back end to the front end you need to trigger a redraw of the table https://datatables.net/reference/api/draw()
"When you perform an action such as adding or deleting a row, changing the sorting, filtering or paging characteristics of the table you'll want DataTables to update the display to reflect these changes. This function is provided for that purpose."
Then use this to redraw the table every couple of seconds:
https://www.w3schools.com/jsref/met_win_setinterval.asp
e.g. like this if you wanted to redraw your table every 3 seconds:
Hello,
I think this discussion can help you:
https://datatables.net/forums/discussion/45393/add-a-row-created-callback-to-my-datatable#latest
//
Este post puede interesarte:
https://datatables.net/forums/discussion/45393/add-a-row-created-callback-to-my-datatable#latest