This commit is contained in:
Daniel 2024-04-15 13:27:19 +08:00
parent 483ae3b671
commit a049eeec3e
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 21 additions and 11 deletions

View file

@ -119,13 +119,19 @@ func (value *Value) Compare(other *Value, attrView *AttributeView) int {
return 0 return 0
} }
case KeyTypeSelect, KeyTypeMSelect: case KeyTypeSelect, KeyTypeMSelect:
if 0 < len(value.MSelect) && 0 < len(other.MSelect) { if nil != value.MSelect && nil != other.MSelect {
v1 := value.MSelect[0].Content var v1 string
v2 := other.MSelect[0].Content for _, v := range value.MSelect {
if v1 == v2 { v1 += v.Content
return 0 break
}
var v2 string
for _, v := range other.MSelect {
v2 += v.Content
break
} }
// 按设置的选项顺序排序
key, _ := attrView.GetKey(value.KeyID) key, _ := attrView.GetKey(value.KeyID)
if nil != key { if nil != key {
optionSort := map[string]int{} optionSort := map[string]int{}

View file

@ -213,13 +213,17 @@ func (table *Table) SortRows(attrView *AttributeView) {
sorted := true sorted := true
for _, colIndexSort := range colIndexSorts { for _, colIndexSort := range colIndexSorts {
val1 := editedRows[i].Cells[colIndexSort.Index].Value val1 := editedRows[i].Cells[colIndexSort.Index].Value
if nil == val1 {
return colIndexSort.Order == SortOrderAsc
}
val2 := editedRows[j].Cells[colIndexSort.Index].Value val2 := editedRows[j].Cells[colIndexSort.Index].Value
if nil == val2 { if nil == val1 || val1.IsEmpty() {
return colIndexSort.Order != SortOrderAsc if nil != val2 && !val2.IsEmpty() {
return false
}
sorted = false
continue
} else {
if nil == val2 || val2.IsEmpty() {
return true
}
} }
result := val1.Compare(val2, attrView) result := val1.Compare(val2, attrView)