TanStackT
TanStack2mo ago
35 replies
wet-harlequin

Get header name

Hi all,

I am currently using a dropdown to hide certain columns. The issue I am running into is that I cannot find a function that allows me to retrieve the header of the column I am working with.

This results in the problem shown in the attached screenshots.


<UDropdownMenu
  :items="
    table?.tableApi
      ?.getAllColumns()
      .filter((column: any) => column.getCanHide())
      .map((column: any) => {
        console.log(column);
        return {
          label: upperFirst(column.id),
          type: 'checkbox' as const,
          checked: column.getIsVisible(),
          onUpdateChecked(checked: boolean) {
            table?.tableApi?.getColumn(column.id)?.toggleVisibility(!!checked)
          },
          onSelect(e?: Event) {
            e?.preventDefault()
          }
        }
      })
  "
  :content="{ align: 'end' }"
>
  <UButton
    label="Display"
    color="neutral"
    variant="outline"
    trailing-icon="i-lucide-settings-2"
  />
</UDropdownMenu>
image.png
Was this page helpful?