Creating a ScrollingTable

lib-st is a factory. It creates and returns an instance of a scrolling table for you to use.

To create a scrolling table

<tt>
local ScrollingTable = LibStub("ScrollingTable");
local table = ScrollingTable:CreateST();
</tt>

Calling CreateST without any arguments will return a default testing table.
Click here for more info on the CreateST function.

After creating a scrolling table, you have to load it with data.
Click here for more information on the SetData function.

You can register event handlers for various frame events!
Click here for more information on the RegisterEvents function.

The sorting of the table is NON-DESTRUCTIVE. This means that the order of rows will remain the same, and you can update the data table after you have set it with new information if you need to. If you update data that needs to be sorted, call the SortData function on the scrolling table.

If you just want to update a color value, a simple Refresh call will do fine.

<tt>
local ScrollingTable = LibStub("ScrollingTable");
local table = ScrollingTable:CreateST(cols);
table:SetData(data);

-- if data is updated
table:SortData(); -- no need to call Refresh, it is called internally.

-- if a color is updated
table:Refresh();

-- set a row filter function
table:SetFilter(fnFilter);
</tt>

example filter function:

<tt>
fnFunction = function(self, row)
    -- only show rows who's 1st column value is > 10
    local show = false;
    if row.cols[1].value > 10 then 
        show = true;
    end
    return show;
end;
</tt>

Assigning a filter function will resort your table. Remember, you can edit the data set you supply to the scrolling table at any time to update the display. Even removing or adding rows. It's a good idea in practice to resort the table after an edit.


Comments

Posts Quoted:
Reply
Clear All Quotes