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?

stevencmonstevencmon Posts: 5Questions: 2Answers: 2

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

  • allanallan Posts: 43,187Questions: 1Answers: 5,628 Site admin

    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

  • stevencmonstevencmon Posts: 5Questions: 2Answers: 2

    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:

    CREATE OR REPLACE VIEW `equipment_bom` AS
      SELECT
        site_id,
        equipment_type,
        used_for,
        sum( quantity ) AS quantity,
        UUID() AS id
      FROM
        new_equipment
      GROUP BY
        site_id,
        equipment_type,
        used_for
    

    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()

  • stevencmonstevencmon Posts: 5Questions: 2Answers: 2
    Answer ✓

    event was the key. just needed to add:
    $('#'+table_id ).on('draw.dt', function() { equipment_bom.ajax.reload(); } );
    In the right place.

Sign In or Register to comment.