View Single Post
09/05/15, 06:03 AM   #9
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
Should've posted more concrete code -- but it was way too late, sorry -- to show why overriding New isn't needed at all thanks to how it's written (it passes all arguments to Initialize).

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

This way CustomerListContainer is not hard-coded in the class, thus you could create multiple instances (on different container controls). Not really useful in your case, I know, but still cleaner IMO.

Another little suggestion that's good getting used to. In BuildMasterList(), don't create a new table, discarding the old one -- unless you have a million items in there and really want to free the memory and only insert a thousand -- just clear the existing table with
Lua Code:
  1. ZO_ClearNumericallyIndexedTable(self.masterList)
  Reply With Quote