vue3-easy-data-table icon indicating copy to clipboard operation
vue3-easy-data-table copied to clipboard

Sorting not wirking properly when the column data are numbers

Open lucasboh opened this issue 2 years ago • 7 comments

If the data of one column are numbers, the sorting does not work properly, as it treats the data as it were strings. See column "Precio de oferta" in the images

image image

Here is my code for the headers:

const headers: Header[] = [
  { text: 'ID', value: 'id', sortable: true },
  { text: 'Fecha', value: 'attributes.createdAt', sortable: true },
  { text: 'Precio de Oferta', value: 'attributes.price', sortable: true },
  { text: 'Periodo de entrega', value: 'attributes.deliveryPeriod', sortable: true },
  { text: 'Condición de pago', value: 'attributes.paymentCondition', sortable: true },
  { text: 'Email', value: 'attributes.user.data.attributes.emailContact', sortable: true },

Is there a way to declare the data type of one column or to use a custom function for the sorting?

lucasboh avatar Jun 01 '23 10:06 lucasboh

I do not have the mentioned issues when using numbers. Make sure that the data realy contains items of the type Number and you format the number via an item-slot (e.g. to add the periods . as a localized form).

jxn-30 avatar Jun 11 '23 08:06 jxn-30

Hello Friends ! Excellent component! But the Client Sorting is not working correctly especially when the column has numbers

The same bug @lucasboh !

image

Thanks in advance !

pinheiroweb avatar Nov 16 '23 22:11 pinheiroweb

Hello @jxn-30 the same problem on the project's official website! https://hc200ok.github.io/vue3-easy-data-table-doc/features/single-field-sorting.html

image

pinheiroweb avatar Nov 16 '23 22:11 pinheiroweb

did anyone come up with a solution for this?

Samiam519 avatar Dec 04 '23 20:12 Samiam519

found my problem: the property and value you want to sort by has to exist in the item object, it cant be derived in the item template

Samiam519 avatar Dec 05 '23 17:12 Samiam519

@Samiam519

found my problem: the property and value you want to sort by has to exist in the item object, it cant be derived in the item template

can you explain please how to solved ? I'm very interested to this issue.

clabnet avatar Feb 10 '24 09:02 clabnet