Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

193
Visualizações
How can i set a default selection in PrimeNG Treetable

I want to set the selection with the value i get from Local-Storage. Here is the code:

HTML:

<p-treeTable [value]="tableDataRow$ | async"
               [columns]="checkColumnNotFixed()"
               selectionMode="single"
               [(selection)]="selectedRow"
>

TS:

public selectedRow;

 ngOnInit(): void {
    this.selectedRow = LocalStorageSelectedRow;
  }

The value is set and can be shown in the console, but in the UI, the row is not selected.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I don't know if my answer could help someone, but the thing that I do is assign to the model variable (selected row in this example) the values which I want to be selected. also I set a variable in the component called "compareSelectionBy", and set its value with "deepEquals".

Example : in the ts

this model =[ 
      { data: { name: 'Applications', size: '200mb', type: 'Folder' } },
      { data: { name: 'Angular', size: '25mb', type: 'Folder' } },
      { data: { name: 'Cloud', size: '20mb', type: 'Folder' } },
      { data: { name: 'backup-1.zip', size: '10mb', type: 'Zip' } },
      { data: { name: 'backup-2.zip', size: '10mb', type: 'Zip' } },]

in the html:

<p-treeTable
  [value]="items"
  [columns]="to.columns"
  selectionMode="checkbox"
  [(selection)]="model"
  [paginator]="to.paginator"
  [rows]="to.rows"
  (onNodeSelect)="onNodeSelect()"
  (onNodeUnselect)="onNodeUnselect()"
  compareSelectionBy="deepEquals"
  #tt
></p-treeTable>
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda