[outdated] ZO_ComboBox sort order
ZO_ComboBox allows custom ordering of items via ZO_ComboBox:SetSortOrder(sortOrder, sortType)
I can attach custom data to entries, and use them for sorting, but currently only as tiebreakers. The limitation lies in function ComboBoxSortHelper, where "name" is hardcoded as the primary sort key. I have a combo box with 1 "default" item and a variable number of user-created items. The "default" item shall always be on top of the drop-down list, while the rest should be properly sorted (they can be added/removed at run-time). So I added "priority" key to each entry, the "default" entry has priority=1, user entries have priority=2. Now I want to set "priority" as the primary sort key, and "name" as the tiebreaker, like this: Lua Code:
|
Quote:
Lua Code:
Or probably a better idea would be to just sort the table yourself...or partial do it yourself. Call table.sort & call your own sort function to check if one of the items is the item you want at the top of the list & return the appropriate value, else pass it on to the ZO_TableOrderingFunction to sort by name. Lua Code:
Oh, and if your storing other data in there besides name and were wanting to sort by that, you could still do the same thing just alter it for whatever data you wanted to sort by. You could pass whatever key you want to ZO_TableOrderingFunction, or just do the entire sort yourself in your own MySort() function. You just may also need to manually set (if they need changed): Lua Code:
|
Yes it's perfectly doable. I will SetSortsItems(false) and override UpdateItems() using my desired sort method. I placed this in the Wish-List section as it would be nice if the control allowed me to simply set the primary sort key ;)
|
Quote:
|
Oh and to top if off, I've now discovered a bug. ZO_ComboBox:UpdateItems() begins with this condition:
Lua Code:
But since ZO_SORT_ORDER_DOWN == false, items will not be sorted at all if you specify descending order. The condition should only check m_sortsItems. Edit: the bug extends to SetSortOrder() as well: Lua Code:
m_sortOrder will always end up being UP, because DOWN == false. |
You should also take a look at the enchantment filter for the trading house.
They have a similar problem where they want to sort the list except for the first and last element Code:
-- Sort the tables, ensuring that the first and last entries of each table remain anchored ('any' and 'other' filters). |
Quote:
|
Reviving because:
|
All times are GMT -6. The time now is 05:36 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI