Skip to content

[Question] Re-render table cells #441

@nik-willingham

Description

@nik-willingham

Is there a way to re-render table cells with the existing data?

I have a case where I want to display OTP codes in a column based on a secret from another column. To that end I set the render function for that cell like so:

table.columns.settings[4].render = (data, td, rowIndex, cellIndex) => {
  const secret = table.data.data[rowIndex].cells[cellIndex - 1].text
  if (secret) return window.otplib.authenticator.generate(secret)
  return ' '
}

And then I insert my rows into the table, leaving the 'code' column null. It renders as expected after the insert. I set up a setInterval timer every second to do a table.refresh() (also tried table.update()), but it doesn't do anything. The only way I found to do it without looping through the table and modifying the cells directly is to set table.data.data = [] and re-insert.

It's not a big deal, but am I missing something obvious? Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions