mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
ui: Fix sorter across different components (#8046)
This PR fixes sorting in tables by columns in the UI
This commit is contained in:
parent
b58ffec4cd
commit
66e5d41a15
@ -155,7 +155,7 @@ export default {
|
|||||||
key: columnKey,
|
key: columnKey,
|
||||||
title: this.$t('label.' + String(columnKey).toLowerCase()),
|
title: this.$t('label.' + String(columnKey).toLowerCase()),
|
||||||
dataIndex: columnKey,
|
dataIndex: columnKey,
|
||||||
sorter: function (a, b) { return genericCompare(a[this.dataIndex] || '', b[this.dataIndex] || '') }
|
sorter: (a, b) => { return genericCompare(a[columnKey] || '', b[columnKey] || '') }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (this.columns.length > 0) {
|
if (this.columns.length > 0) {
|
||||||
|
|||||||
@ -861,7 +861,7 @@ export default {
|
|||||||
key: key,
|
key: key,
|
||||||
title: this.$t('label.' + String(title).toLowerCase()),
|
title: this.$t('label.' + String(title).toLowerCase()),
|
||||||
dataIndex: key,
|
dataIndex: key,
|
||||||
sorter: function (a, b) { return genericCompare(a[key] || '', b[key] || '') }
|
sorter: (a, b) => genericCompare(a[key] || '', b[key] || '')
|
||||||
})
|
})
|
||||||
this.selectedColumns.push(key)
|
this.selectedColumns.push(key)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -76,17 +76,17 @@ export default {
|
|||||||
{
|
{
|
||||||
dataIndex: 'name',
|
dataIndex: 'name',
|
||||||
title: this.$t('label.name'),
|
title: this.$t('label.name'),
|
||||||
sorter: function (a, b) { return genericCompare(a[this.dataIndex] || '', b[this.dataIndex] || '') }
|
sorter: (a, b) => genericCompare(a?.name || '', b?.name || '')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
dataIndex: 'type',
|
dataIndex: 'type',
|
||||||
title: this.$t('label.type'),
|
title: this.$t('label.type'),
|
||||||
sorter: function (a, b) { return genericCompare(a[this.dataIndex] || '', b[this.dataIndex] || '') }
|
sorter: (a, b) => genericCompare(a?.type || '', b?.type || '')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
dataIndex: 'description',
|
dataIndex: 'description',
|
||||||
title: this.$t('label.description'),
|
title: this.$t('label.description'),
|
||||||
sorter: function (a, b) { return genericCompare(a[this.dataIndex] || '', b[this.dataIndex] || '') }
|
sorter: (a, b) => genericCompare(a?.description || '', b?.description || '')
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
selectedRowKeys: [],
|
selectedRowKeys: [],
|
||||||
|
|||||||
@ -79,7 +79,7 @@ export default {
|
|||||||
{
|
{
|
||||||
dataIndex: 'name',
|
dataIndex: 'name',
|
||||||
title: this.$t('label.name'),
|
title: this.$t('label.name'),
|
||||||
sorter: function (a, b) { return genericCompare(a[this.dataIndex] || '', b[this.dataIndex] || '') },
|
sorter: (a, b) => genericCompare(a?.name || '', b?.name || ''),
|
||||||
width: '40%'
|
width: '40%'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@ -151,7 +151,7 @@ export default {
|
|||||||
{
|
{
|
||||||
dataIndex: 'name',
|
dataIndex: 'name',
|
||||||
title: this.$t('label.name'),
|
title: this.$t('label.name'),
|
||||||
sorter: function (a, b) { return genericCompare(a[this.dataIndex] || '', b[this.dataIndex] || '') },
|
sorter: (a, b) => genericCompare(a?.name || '', b?.name || ''),
|
||||||
width: '40%'
|
width: '40%'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@ -135,18 +135,18 @@ export default {
|
|||||||
this.columns.push({
|
this.columns.push({
|
||||||
dataIndex: 'name',
|
dataIndex: 'name',
|
||||||
title: this.$t('label.hypervisor'),
|
title: this.$t('label.hypervisor'),
|
||||||
sorter: function (a, b) { return genericCompare(a[this.dataIndex] || '', b[this.dataIndex] || '') }
|
sorter: (a, b) => genericCompare(a?.name || '', b?.name || '')
|
||||||
})
|
})
|
||||||
|
|
||||||
this.columns.push({
|
this.columns.push({
|
||||||
dataIndex: 'hosts',
|
dataIndex: 'hosts',
|
||||||
title: this.$t('label.hosts'),
|
title: this.$t('label.hosts'),
|
||||||
sorter: function (a, b) { return genericCompare(a[this.dataIndex] || '', b[this.dataIndex] || '') }
|
sorter: (a, b) => genericCompare(a?.hosts || '', b?.hosts || '')
|
||||||
})
|
})
|
||||||
this.columns.push({
|
this.columns.push({
|
||||||
dataIndex: 'cpusockets',
|
dataIndex: 'cpusockets',
|
||||||
title: this.$t('label.cpu.sockets'),
|
title: this.$t('label.cpu.sockets'),
|
||||||
sorter: function (a, b) { return genericCompare(a[this.dataIndex] || '', b[this.dataIndex] || '') }
|
sorter: (a, b) => genericCompare(a?.cpusockets || '', b?.cpusockets || '')
|
||||||
})
|
})
|
||||||
|
|
||||||
this.items = []
|
this.items = []
|
||||||
|
|||||||
@ -183,13 +183,13 @@ export default {
|
|||||||
this.columns.push({
|
this.columns.push({
|
||||||
dataIndex: 'name',
|
dataIndex: 'name',
|
||||||
title: this.$t('label.name'),
|
title: this.$t('label.name'),
|
||||||
sorter: function (a, b) { return genericCompare(a[this.dataIndex] || '', b[this.dataIndex] || '') }
|
sorter: (a, b) => genericCompare(a?.name || '', b?.name || '')
|
||||||
})
|
})
|
||||||
|
|
||||||
this.columns.push({
|
this.columns.push({
|
||||||
dataIndex: 'value',
|
dataIndex: 'value',
|
||||||
title: this.$t('label.value'),
|
title: this.$t('label.value'),
|
||||||
sorter: function (a, b) { return genericCompare(a[this.dataIndex] || '', b[this.dataIndex] || '') }
|
sorter: (a, b) => genericCompare(a?.value || '', b?.value || '')
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
getRowClassName (record, index) {
|
getRowClassName (record, index) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user