Skip to content

How to Highlight a Selected Row in n-data-table? #5294

Closed Answered by cefiro
factor200x asked this question in Q&A
Discussion options

You must be logged in to vote

Hi!

The code below creates the ability to select (checkbox) a table row by clicking on any cell.

You can modify it to highlight by adding HTML classes directly to the selector of the cell row of the table

<n-data-table
    v-model:checked-row-keys="checkedRowKeysRef"
    :row-props="changeRowProps"
  />
const checkedRowKeysRef = ref<Array<string | number>>([]);
const changeRowProps = (rowData) => {
        return {
          onClick: (e: PointerEvent) => {
            const el = e.target as HTMLElement;

            if (el.tagName === 'TD') {
              const tr = el.parentNode as HTMLElement;
              if (tr.tagName === 'TR') {
                if (tr.querySelector('.n-data-table…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@factor200x
Comment options

Answer selected by factor200x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants