Thread: ZO_Helpers
View Single Post
10/12/14, 09:37 AM   #7
Argusus
AddOn Author - Click to view addons
Join Date: Sep 2014
Posts: 120
Originally Posted by merlight View Post
I should read more carefully before pasting lines from different places. Now I think it should not suppress the callback, because it sets currentSortKey and currentSortOrder, which are then used in sortFunction.

I'd place it right before RefreshData call, without SUPPRESS_CALLBACK:

Lua Code:
  1. function UnitList:Initialize()
  2.     self.masterList = {}
  3.     ZO_ScrollList_AddDataType(self.list, 1, "UnitRow", 30, function(control, data) self:SetupUnitRow(control, data) end)
  4.     ZO_ScrollList_EnableHighlight(self.list, "ZO_ThinListHighlight")   
  5.     self.sortFunction = function(listEntry1, listEntry2) return ZO_TableOrderingFunction(listEntry1.data, listEntry2.data, self.currentSortKey, UnitList.SORT_KEYS, self.currentSortOrder) end
  6.     self.sortHeaderGroup:SelectHeaderByKey("name")
  7.     self:RefreshData()
  8. end

I'm still wondering how it could work without setting a sort key. I'd expect it to throw a "nil used as table key" error when there are 2 or more items in the list.
Worked like a charm! thank you.
  Reply With Quote