Using getIndex with Tabulator

I have a “Solution”, not sure if this is the best way to do this.

Here I changed cell_click to return the cell instead of the row data in dictionary form.

This allows me to call cell.getRow() to get the row object. Then I can run row.update(<new data dictionary>) on the row object to update my table. I was attempting to update using tabulator.update_row(), but this requires you to know the index and I could not figure out how the indexing works with this Tabulator Wrapper.

Here is the code working:


  def tabulator_company_cell_click(self, field, cell, **event_args):
    """This method is called when a cell is clicked - event_args include field and row"""

    if field =='edit':
      form = get_open_form()
      row_data = dict(cell.getData())
      alert(content=EditCustomer(prev_form=form,cust_id=row_data['_id'],),
          large=True,buttons=[])
      if self.row_updated_flag:
        data = anvil.server.call('get_tabular_company_by_id',row_data['_id'])
        row = cell.getRow()
        row.update(data[0])
      self.row_updated_flag = False

Here I have table with an “edit” column which opens my EditCustomer form as an alert. There the user can edit the customer. When they click “Save Changes” in this form it closes the alert and publishes a message to my tabulator form which then sets the self.row_update_flag to True. I then grab the updated data from my server and update the row in my table.

I could potentially avoid changing the Tabulator Wrapper source code if I could figure out how to get the index of the row and understand how the self._index attribute works in the Tabulator class. I would like to keep my dependencies to the github repo, but this a work around for those trying the same.

Thanks!