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

408
Visualizações
CoreUI DataTable sort values by specific column values

Right now, it's not showing sorted result according to title. I want to show the rows by default in ascending.

Please have a look:

enter image description here

Below is my code:

const fields = [
  { key: 'title', _classes: 'font-weight-bold' },
  { key: 'category', _style: { width: '20%'} }
]
<CDataTable
    items={list}
    fields={fields}
    columnFilter
    tableFilter={{ 'placeholder': 'Type something...'}}
    itemsPerPageSelect
    itemsPerPage={5}
    hover
    sorter
    pagination
/>

Note: From the Documentation: I have tried something i.e. sorter={{'resetable': 'ascending'}} but nothing works for me.

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

0

There's two points:

  1. For descending sort you must set asc:false
  2. Default sort value must pass to sorterValue option in CDataTable

So , you can try this:

<CDataTable
    items={list}
    fields={fields}
    columnFilter
    tableFilter={{ 'placeholder': 'Type something...'}}
    itemsPerPageSelect
    itemsPerPage={5}
    hover
    sorter
    sorterValue={{column: "title", asc: true}}
    pagination
/>
about 4 years ago · Juan Pablo Isaza Relatório

0

Here is how it works for me:

<CDataTable
  items={list}
  fields={fields}
  columnFilter
  tableFilter={{ 'placeholder': 'Type something...'}}
  itemsPerPageSelect
  itemsPerPage={5}
  hover
  sorter
  sorterValue={{column: "title", asc: true}}
  onSorterValueChange={(params) => {
    if (params.column === order.sorting.column && params.asc === order.sorting.asc) return;
    dispatch(actions.getOrders(.....));
    dispatch(actions.sortingChanged(params));
  }}
  pagination
/>

You should avoid cyclic code call by making sure in onSorterValueChange() that params.column & params.asc are not equal to what is already set. If true - return; otherwise - call your API request and change state with new sorting params.

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