Originally Posted by skobyjay
is there a "descending" version of that by chance?
|
sort order is the last argument passed to the:
ZO_TableOrderingFunction(entry1, entry2, sortKey, sortKeys, sortOrder)
sortOrder can be either ZO_SORT_ORDER_UP (true) or ZO_SORT_ORDER_DOWN (false)
In the ScrollListExample sort order could be set directly:
lua Code:
self.sortOrder = ZO_SORT_ORDER_DOWN
or using the OnSortHeaderClicked(key, order) method inherited from the main class ZO_SortFilterList:
lua Code:
self:OnSortHeaderClicked("name", ZO_SORT_ORDER_DOWN)
Changed code to use direct access to sort order:
lua Code:
function UnitList:Initialize()
self.masterList = {}
ZO_ScrollList_AddDataType(self.list, 1, "UnitRow", 30, function(control, data) self:SetupUnitRow(control, data) end)
ZO_ScrollList_EnableHighlight(self.list, "ZO_ThinListHighlight")
self.currentSortKey = "name"
self.currentSortOrder = ZO_SORT_ORDER_DOWN
self.sortFunction = function(listEntry1, listEntry2) return ZO_TableOrderingFunction(listEntry1.data, listEntry2.data, self.currentSortKey, UnitList.SORT_KEYS, self.currentSortOrder) end
self:RefreshData()
end
Changed code to use OnSortHeaderClicked:
lua Code:
function UnitList:Initialize()
self.masterList = {}
ZO_ScrollList_AddDataType(self.list, 1, "UnitRow", 30, function(control, data) self:SetupUnitRow(control, data) end)
ZO_ScrollList_EnableHighlight(self.list, "ZO_ThinListHighlight")
self.sortFunction = function(listEntry1, listEntry2) return ZO_TableOrderingFunction(listEntry1.data, listEntry2.data, self.currentSortKey, UnitList.SORT_KEYS, self.currentSortOrder) end
self:SetLockedForUpdates(true) --lock for updates, so list will be refreshed only once
self:OnSortHeaderClicked("name", ZO_SORT_ORDER_DOWN)
self:RefreshData()
self:SetLockedForUpdates(false) --when unlocked, all pending refresh functions will be called
end