What is the best way to refresh a table when another table changes?
What is the best way to refresh a table when another table changes?
I have several JQuery UI tabs in which a list of resources related to the specific tab is maintained. In the tab 'A; it might be enter that we need 27 boxes and 37 lids, in tab 'B' it might say that we need 10 boxes and 8 lids. I also have a tab named 'summary' that will display a table showing 37 boxes and 45 lids. this table is fed by a 'view' that does and sum() and group by.
My question is how to trigger a 'summary' table refresh when any of the related tables change?
This question has an accepted answers - jump to answer
Answers
Assuming you are Ajax loading the data for the summary table and you want to get new data for it from the server, you could use
ajax.reload()
. If the summary data is generated in some other way, I'd really know to know what that is in order to be able to make any suggestions.Allan
okay, an extended description.
I have an equipment table with the following columns: id, site_id, area_id, equipment_type, used_for, quantity.
I have a DataTable defined for each distinct area that is populated using the JS passing back in the AJAX "area_id": area_id and in the php side doing a
->where( 'area_id', ' $POST['area_id']
.I also have a separate DataTable that I want to summarize all of the equipment table rows for a given site. I have created a mysql view:
This is all working well, with the exception that the bom equipment DataTable doesn't update automagically... More reading tells me that I need to set up an event of some kind in order to do the ajax.reload()
event was the key. just needed to add:
$('#'+table_id ).on('draw.dt', function() {
equipment_bom.ajax.reload();
} );
In the right place.