element icon indicating copy to clipboard operation
element copied to clipboard

[Bug Report] Sort of table not working when data contains null

Open howard-repos opened this issue 5 years ago • 4 comments

Element UI version

2.13.0

OS/Browsers version

win10/chrome

Vue version

2.6.11

Reproduction Link

https://codepen.io/kabike/pen/jOPxBpJ?editors=1010

Steps to reproduce

点击“姓名”列的排序

What is Expected?

null的数据在排序时应该相邻

What is actually happening?

null的数据在排序时不相邻

howard-repos avatar Mar 16 '20 07:03 howard-repos

Translation of this issue:

Element UI version

2.13.0

OS/Browsers version

Win10/chrome

Vue version

2.6.11

Reproduction Link

https://codepen.io/kabike/pen/jOPxBpJ?editors=1010

Steps to reproduce

Click the sorting of "name" column

What is Expected?

Null data should be adjacent when sorting

What is actually happening?

Null data is not adjacent when sorting

element-bot avatar Mar 16 '20 07:03 element-bot

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jul 23 '21 06:07 stale[bot]

相同问题

pscj avatar Apr 05 '22 12:04 pscj

I get this error with null values, if sorted in descending order it seems to work half way by placing the null value at the beginning of the rows when it should be at the end of the rows:

image

When trying to sort in ascending order, the sorting fails, the null value should be at the beginning of the rows:

image

I was able to apply a partial correction by handling the records that go into the data table, adding an additional column with the prefix of SORT_:

const recordsList = records.map((record, rowIndex) => {
  // TODO: Test peformance.
  Object.keys(record).forEach(key => {
    const currentValue = record[key]
      // Add column with sort values to correct sorting
      let sortValue = ''
      if (currentValue !== null && currentValue !== undefined) {
        sortValue = currentValue.toLowerCase()
      }
      record['SORT_' + key] = sortValue
  })
  return {
    ...record
  }
})

And in the-column place the sort-by property (SORT_ + key) of the new column added to the records.

EdwinBetanc0urt avatar Jun 24 '24 06:06 EdwinBetanc0urt