The best is to use the legacy ZO functions :
Your XML should look like this :
Lua Code:
<TopLevelControl name="Scene_KC_Menu_Spells" inherits="ZO_RightPanelFootPrint" hidden="true">
<Controls>
<Control name="$(parent)Headers">
<Dimensions x="600" y="32" />
<Anchor point="TOPLEFT" relativeTo="$(parent)" relativePoint="TOPLEFT" offsetX="300" offsetY="50"/>
<Controls>
<Control name="$(parent)AbilityName" inherits="ZO_SortHeader">
<OnInitialized>
ZO_SortHeader_Initialize(self, "Ability Name", "abilityname", ZO_SORT_ORDER_DOWN, TEXT_ALIGN_LEFT, "ZoFontGameLargeBold")
</OnInitialized>
<Anchor point="TOPLEFT" relativeTo="$(parent)" />
<Dimensions x="250" y="32" />
</Control>
<Control name="$(parent)KillingBlows" inherits="ZO_SortHeader">
<OnInitialized>
ZO_SortHeader_Initialize(self, "Killing Blows", "killingblows", ZO_SORT_ORDER_DOWN, TEXT_ALIGN_LEFT, "ZoFontGameLargeBold")
</OnInitialized>
<Anchor point="TOPLEFT" relativeTo="$(parent)AbilityName" relativePoint="TOPRIGHT"/>
<Dimensions x="150" y="32" />
</Control>
<Control name="$(parent)AvgHit" inherits="ZO_SortHeader">
<OnInitialized>
ZO_SortHeader_Initialize(self, "AvgHit", "avghit", ZO_SORT_ORDER_DOWN, TEXT_ALIGN_LEFT, "ZoFontGameLargeBold")
</OnInitialized>
<Anchor point="TOPLEFT" relativeTo="$(parent)KillingBlows" relativePoint="TOPRIGHT"/>
<Dimensions x="100" y="32" />
</Control>
<Control name="$(parent)MaxHit" inherits="ZO_SortHeader">
<OnInitialized>
ZO_SortHeader_Initialize(self, "MaxHit", "maxhit", ZO_SORT_ORDER_DOWN, TEXT_ALIGN_LEFT, "ZoFontGameLargeBold")
</OnInitialized>
<Anchor point="TOPLEFT" relativeTo="$(parent)AvgHit" relativePoint="TOPRIGHT"/>
<Dimensions x="100" y="32" />
</Control>
</Controls>
</Control>
<Control name="$(parent)List" inherits="ZO_ScrollList">
<Dimensions x="600" y="575" />
<Anchor point="TOPLEFT" relativeTo="$(parent)Headers" relativePoint="TOPLEFT" offsetX="0" offsetY="40" />
</Control>
</Controls>
</TopLevelControl>
This is a list with 5 columns, sortable, scrollable.
Then, in LUA :
- Use LibMainMenu-2 from Votan Potion Maker addon (We should merge the v1 and v2 a day...) to add a tab.
- Build it.
- Init your tab in OnAddonLoaded() func.
Lua Code:
function killingBlowsList:New(control)
ZO_SortFilterList.InitializeSortFilterList(self, control)
local sorterKeys =
{
["abilityname"] = {tiebreaker = "killingblows"},
["killingblows"] = {isNumeric = true}, -- the default column.
["avghit"] = {tiebreaker = "killingblows"},
["maxhit"] = {tiebreaker = "killingblows"},
}
self.masterList = {}
ZO_ScrollList_AddDataType(self.list, 1, "KillCounterKillingBlowRowTemplate", 32, function(control, data) self:SetupEntry(control, data) end)
ZO_ScrollList_EnableHighlight(self.list, "ZO_ThinListHighlight")
self.currentSortKey = "killingblows"
self.sortFunction = function(listEntry1, listEntry2) return ZO_TableOrderingFunction(listEntry1.data, listEntry2.data, self.currentSortKey, sorterKeys, self.currentSortOrder) end
self:SetAlternateRowBackgrounds(true)
return self
end
function killingBlowsList:SetupEntry(control, data)
control.data = data
control.abilityname = GetControl(control, "AbilityName")
control.killingblows = GetControl(control, "KillingBlows")
control.avghit = GetControl(control, "AvgHit")
control.maxhit = GetControl(control, "MaxHit")
-- You can reformat how ever you want.
control.abilityname:SetText(data.abilityname)
control.killingblows:SetText(data.killingblows)
control.avghit:SetText(data.avghit)
control.maxhit:SetText(data.maxhit)
ZO_SortFilterList.SetupRow(self, control, data)
end
function killingBlowsList:BuildMasterList()
self.masterList = {}
local killingBlows = db.KillingBlowList -- My SV
if killingBlows then
for k, v in ipairs(killingBlows) do
local data = v
table.insert(self.masterList, data)
end
end
end
function killingBlowsList:SortScrollList()
local scrollData = ZO_ScrollList_GetDataList(self.list)
table.sort(scrollData, self.sortFunction)
end
function killingBlowsList:FilterScrollList()
local scrollData = ZO_ScrollList_GetDataList(self.list)
ZO_ClearNumericallyIndexedTable(scrollData)
for i = 1, #self.masterList do
local data = self.masterList[i]
table.insert(scrollData, ZO_ScrollList_CreateDataEntry(1, data))
end
end
function KillCounter_HoverRowOfKillingBlows(control)
killingBlowsList:Row_OnMouseEnter(control)
end
function KillCounter_ExitRowOfKillingBlows(control)
killingBlowsList:Row_OnMouseExit(control)
end
local function OnAddonLoaded()
-- things includeing the init of the tab.
killingBlowData = killingBlowsList:New(Scene_KC_Menu_Spells)
killingBlowData:RefreshData()
cleanSortListForDB("KillingBlowList") -- this func must remove the dataEntry recursive array if your list will go in SavedVars
An exemple of what it does ( It's not finished , I know
) :