Ask Your Question

Revision history [back]

Unable to row update using ajax in a table

Hi,

I have the following class MyTable used as my index table in views.py. I have modified my code to explain what I want to achieve.

#FILENAME table.py

    class UpdateRow(tables.Row):
        ajax = True
        def get_data(self, request, myrow_id):
            LOG.debug(("Update Row Called", myrow_id))
            row_entry = # RETURN VALUE OF AN API CALL
            return row_entry

    class MyTable ( tables.DataTable):
    # some tables.column attributes
    class Meta:
        name = "mytable"
        verbose_name = _("My Table")
        row_class = UpdateRow
        table_actions = (CreateRow, DeleteRow)

When I load the page on the dashboard, I can see the index page getting loaded properly but I don't see get_data of the UpdateRow being called. Neither the values on the dashboard, nor the log files show any changes. I have imitated what instances panel do to AJAX call for individual row.

Wanted to know if I have missed a step or did something wrong. Any help would be great!

Note: HORIZON_CONFIG dictionary in settings.py has no entry for 'ajax_poll_interval' but it should take it as 2.5 seconds timeout for auto-refresh for default.

Unable to Horizon - unable to update row update using ajax in a table

Hi,

I have the following class MyTable used as my index table in views.py. I have modified my code to explain what I want to achieve.

#FILENAME table.py

    class UpdateRow(tables.Row):
        ajax = True
        def get_data(self, request, myrow_id):
            LOG.debug(("Update Row Called", myrow_id))
            row_entry = # RETURN VALUE OF AN API CALL
            return row_entry

    class MyTable ( tables.DataTable):
    # some tables.column attributes
    class Meta:
        name = "mytable"
        verbose_name = _("My Table")
        row_class = UpdateRow
        table_actions = (CreateRow, DeleteRow)

When I load the page on the dashboard, I can see the index page getting loaded properly but I don't see get_data of the UpdateRow being called. Neither the values on the dashboard, nor the log files show any changes. I have imitated what instances panel do to AJAX call for individual row.

Wanted to know if I have missed a step or did something wrong. Any help would be great!

Note: HORIZON_CONFIG dictionary in settings.py has no entry for 'ajax_poll_interval' but it should take it as 2.5 seconds timeout for auto-refresh for default.