How to sort the Angular table by Date order?

0

Notice the table

Isthereanywaytosortthetablesoit'salwaysinthedateorder?

ThisismyHTMLcode;

<p-dataTable[value]="noticias" [paginator]="true"
   emptyMessage="Nenhum lançamento encontrado"
  [responsive]="true"
  [rows]="filtro.itensPorPagina"
  [lazy]="true" [totalRecords]="totalRegistros"
  (onLazyLoad)="aoMudarPagina($event)"
  #tabela>

  <p-column field="dataNoticia" header="Data da noticia" styleClass="col-data"></p-column>
  <p-column field="titulo" header="Titulo"></p-column>
   <p-column field="font" header="Fonte" styleClass="col-valor"></p-column>
      <p-column styleClass="col-acoes">
          <ng-template let-lanc="rowData" pTemplate="body">
            <button pButton icon="fa-pencil"
            pTooltip="Editar" tooltipPosition="top"
            [routerLink]="['/noticiasad', lanc.codigo]" ></button>

            <button pButton icon="fa-trash"
            pTooltip="Excluir" tooltipPosition="top"
            (click)="confirmarExclusao(lanc)"></button>
          </ng-template>
        </p-column>
  </p-dataTable>

I'm using Angular 4

===============================================

Based on this link

How can I set the default sort order on the primeng datatable?

It looks like this;

<p-dataTable [value]="noticias" [paginator]="true"

      sortField="dataNoticia" sortOrder="-1"

       emptyMessage="Nenhum lançamento encontrado"
      [responsive]="true"
      [rows]="filtro.itensPorPagina"
      [lazy]="true" [totalRecords]="totalRegistros"
      (onLazyLoad)="aoMudarPagina($event)"
      #tabela>

      <p-column field="dataNoticia" header="Data da noticia" styleClass="col-data">
        <ng-template let-lanc="rowData" pTemplate="body">
          <span>{{ lanc.dataNoticia | date:'dd/MM/yyyy' }}</span>
        </ng-template>

      </p-column>
      <p-column field="titulo" header="Titulo"></p-column>
       <p-column field="font" header="Fonte" styleClass="col-valor"></p-column>
          <p-column styleClass="col-acoes">
              <ng-template let-lanc="rowData" pTemplate="body">
                <button pButton icon="fa-pencil"
                pTooltip="Editar" tooltipPosition="top"
                [routerLink]="['/noticiasad', lanc.codigo]" ></button>

                <button pButton icon="fa-trash"
                pTooltip="Excluir" tooltipPosition="top"
                (click)="confirmarExclusao(lanc)"></button>
              </ng-template>
            </p-column>
      </p-dataTable>

But I did not succeed.

    
asked by anonymous 08.03.2018 / 19:59

0 answers