lib-ScrollingTable

lib-st in action!

lib-st provides a convenient way to create and display a scrolling table of data.
Supply column info and your table data, and you're off!

To get a handle in lua:

local ScrollingTable = LibStub("ScrollingTable");

To package in your addon, add to your .pkgmeta file:

externals:
    Libs/lib-st: 
        url: svn://svn.wowace.com/wow/lib-st/mainline/trunk
        tag: latest

Leave off the tag line if you want the absolute lastest alpha version from the site. (I try to keep a stable copy tagged as latest)

New Features:

Added support for calling SetData with a minimal dataset which can drastically reduce the number of tables that exist within the mod... at a slight cost to customization.

Other recent changes

If no args or colorargs are specified for value and color functions, respectively, instead of no args, these args will be passed:

function (data, cols, realrow, column, sttable)  
    -- sttable is a reference to the scrolling table
end

Here's some nitty-gritty:

  • Set names and widths of columns, lib-st will set the table width on it's own!
  • Set the number of rows, and a value to use for row height, lib-st will set the table height on it's own!
  • Set background colors for each column.
  • Set column text alignment.
  • Set column text color.
  • Set row text color.
  • Set text color on a cell-by-cell basis.
  • Supply functions to be evaluated for cell data, and cell/row/column text colors!
  • Filter table data via a filter funtion.
  • Table sorts are NON-DESTRUCTIVE. Data or the order of data supplied is never changed (unless modified by user supplied functions) for the display of the table. No copies of the data are made either. 1 Table, your data, sort it, index it as it was when it was created, update it as you see fit.
  • Hookable ui events. find out more here
  • Custom cell formatting with a custom display function
  • Enable selection on your scrolling table


Find out how to create a scrolling table using lib-st!
Let me know if you use it!!

-> Screenshots

Known consumers of lib-st

You must login to post a comment. Don't have an account? Register to get one!

  • Avatar of Allara Allara Jun 17, 2010 at 21:53 UTC - 0 likes

    ddumont, does lib-st currently support putting buttons in the table? Looks like it doesn't. I'm envisioning an "Edit" button on every row of the table. This button could just call a function when clicked. I'd then open up a new edit window.

    I've never used lib-st before, so I'm just evaluating if it makes sense in my upcoming add-on. Is there perhaps a better or different way to achieve the above? I have a long list of things that I want users to edit or delete.

  • Avatar of ddumont ddumont Mar 19, 2010 at 14:13 UTC - 0 likes

    Hmm... that's a pretty big change. I'm going to think about it and see if I can come up with something... I think I see what you're talking about.

    I'll also take a look if you want to send some changes over. I won't be able to finish this for a few weeks, I have some other stuff that I'm working on and my job is keeping me busy. But I agree this would be a nice change to have.

  • Avatar of lilsparky lilsparky Mar 19, 2010 at 00:33 UTC - 0 likes

    doing some work on another mod that i intend to use lib-st, but i'm dying for grouping mechanics. it occurs to me that since you're passing the data and realrow, then it's possible that only a bit of reworking would be necessary to get grouping going.

    what you'd do is have a data field for any item that's a group header. that data field would be just like the main data field (ie, indexed array of items with a cols array, user data, and potentially a data subfield). group headers would need to have an expanded/collapsed flag as well. probably would need to associate the filtered array into the data table itself so that subgroup data fields would also have a filtered table go with them.

    sorting would be recursive. i THINK you could handle that right in the compare (when comparing a header, if it's contents aren't sorted then you sort them and set the flag saying they're sorted).

    filtering should just iterate over all items (again using recursion).

    the display becomes the biggest issue - how do you scroll down the list easily? you can't just start the display loop with item number 275 (for example) you need to calculate what item that is. that might be a fast calculation, so maybe it's not a problem, but since it'd need to fire every time you redraw, some better solution would be good to figure out...

    anyway, what are your thoughts on this? i could attempt to implement this in my local copy and send you the changes. it should be able to work without breaking compatability with current users... i think...

    Last edited Mar 19, 2010 by lilsparky
  • Avatar of ddumont ddumont Dec 20, 2009 at 05:13 UTC - 0 likes

    :) Thanks!

  • Avatar of chaosknightz chaosknightz Dec 20, 2009 at 04:47 UTC - 0 likes

    works great thanks for all the help, you rock!

  • Avatar of ddumont ddumont Dec 19, 2009 at 21:13 UTC - 0 likes

    Hi. As for the ace gui frame, make sure you are getting the actual frame object. I think it's something like:

        local parent = aceframe.frame;
    

    About the repetition of 1 guildy, there seems to be some problems with the way you are looping. I copied your example, and my proposed changes over here: http://paste.wowace.com/1570/

    Also, please create a wowace project for your mod and have it link to me by embedding my library in your mod. I get points, and if your mod is popular, so will you!

    Last edited Dec 19, 2009 by ddumont
  • Avatar of chaosknightz chaosknightz Dec 19, 2009 at 18:33 UTC - 0 likes

    im having problems with two things atm. the first is trying to define a parent for the scrolling table when i have a ace gui frame mde. the other is avtually getting the data to populate correctly. the only thing i have been able to sucessfully do is get the name, rank and level of one person from the guild and their data repeated throughout the table. eveyrthing else i have tried has resulted in an error. here is the code:

    local ScrollingTable = LibStub("ScrollingTable");
    local cols = {
        {
            ["name"] = "Name",
             ["width"] = 100,
             ["color"] = { ["r"] = 0.5, ["g"] = 0.5, ["b"] = 1.0, ["a"] = 1.0 },
        },
        {
            ["name"] = "Rank",
            ["width"] = 100,
            ["align"] = "CENTER",
            ["bgcolor"] = { ["r"] = 1.0, ["g"] = 0.0, ["b"] = 0.0, ["a"] = 0.2 },
        },
        {
            ["name"] = "Level",
            ["width"] = 100,
            ["align"] = "RIGHT",
            ["bgcolor"] = { ["r"] = 0.0, ["g"] = 0.0, ["b"] = 0.0, ["a"] = 0.5 },
        },
    };
    local st = ScrollingTable:CreateST(cols);
    local gdata = {}
    for row = 1, GetNumGuildMembers() do
        if not gdata[row] then
            gdata[row] = {};
        end
        for col = 1, 3 do
            if not gdata[row].cols then
                gdata[row].cols = {};
            end
               for i = 1, GetNumGuildMembers() do
         local name, rank, rankIndex, level, class, zone, note, officernote, online, status, classFileName = GetGuildRosterInfo(i)
             gdata[row].cols[1] = { ["value"] = name };
             gdata[row].cols[2] = { ["value"] = rank };
             gdata[row].cols[3] = { ["value"] = level };
        end
    end
    st:SetData(gdata);
    end
    end

    Last edited Dec 19, 2009 by chaosknightz
  • Avatar of ddumont ddumont Dec 10, 2009 at 12:41 UTC - 0 likes

    Hi!

    Thanks for pointing that out. but I'd recommend using the latest tagged and stable version for testing. Right now the alphas are unstable, I'm trying to put some new support in for someone and haven't had good solid chunks of time to spend on it yet.

  • Avatar of Corg Corg Dec 10, 2009 at 05:37 UTC - 0 likes

    Hi DDumont,

    The latest version of this library appears to have a bug. fRealRow should be renamed to isRealRow.

    	local function GetRow(self, row, isRealRow)
    		if fRealRow then 
    			return self.data[row];
    		else
    			return self.data[self.sorttable[row]];
    		end
    	end
    

    It's messing up the sorting in my mod and I was hoping to get my new mod approved for release this week.

    Thanks!

    Last edited Dec 10, 2009 by Corg
  • Avatar of ddumont ddumont Dec 05, 2009 at 19:13 UTC - 0 likes

    Are you going to put it on wowace? I'd like to link back to you if you decide to use my library. I'm also interested in growing my generated points/day :)

Facts

Date created
Oct 14, 2008
Categories
Last update
Jun 06, 2011
Development stage
Mature
License
GNU General Public License version 2 (GPLv2)
Curse link
lib-ScrollingTable
Reverse relationships
12
Downloads
12,420
Recent files
  • R: v4.0 for 4.1 Jun 06, 2011
  • A: r145 for 4.1 Jun 06, 2011
  • R: v3.9 for 4.0.6 Jun 06, 2011
  • A: r143 for 4.0.6 Jun 06, 2011
  • A: r142 for 4.0.6 Apr 25, 2011

Authors

Relationships

Embedded library
LibStub