lib-ScrollingTable
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: https://github.com/ddumont/lib-st.git 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
I am overriding the display functions as you suggested. Working well. Thanks again.
The easiest way would be to embed the image refs in the string contents of the cell.
The best way would probably be to override the custom display function., you get way more control over how the image is displayed( padding, alignment, etc)
In sdkp there's a slideout panel that has a list of loot that's been assigned for the dkp run. In the table data, I just put the item id string. The column has a display function that reads that in and sets the contents to an image.
What would be the best way of having one row of a table be filled with item icons? Would I just need to have custom display functions for the cells and just do all the icon stuff myself on the cell frame?
Love the library. I have a ton of scroll frames in TradeSkillMaster and am slowly converting them all over to use this library as it's much easier to code and tweak and most importantly looks better :)
Thanks
I don't use SVN. I will include information about used libs in description in next update.
No problem. Can you link to it properly in your addon's .pkgmeta file so that I get credits for you using my lib?
Thank you very much for this lib. I'm using it in my own addon - REFlex - Battleground Historian.
I like the library. I was wondering if you had thought about adding an option to control whether mouseover highlighting is enabled. If you change the highlight color, it also will stop actual row selection from highlighting.
I was able to turn off the row mouseover highlighting by calling RegisterEvent and replace the OnEnter and OnLeave but it seems like it would be nice to just have an option. It's possible in the future that those events could be use internally for other purposes.
Crap, my notifications of posts stopped working....
Have you figured out a solution to your problem? That one sounds easy to fix. You have to anchor the frame to the parent frame.
Hope you can help me :)
when i create a frame that include a scrollingtable created with CreateST this table doesn't move with my main frame and stay in middle of screen. anyway to change this behavoir ?
Sdkp does it... well.. it uses the docellupdate function http://www.wowace.com/addons/lib-st/pages/docell-update/
which was what i was talking about. The sidedrawer on the right contains a list of loot with a custom image and hoverover.
Any documentation on that, or another add-on that does it? I haven't been able to find anything so far. Thanks!
There is definitely a way to do this. There's a draw function for each cell, row, etc, where you can set up any kinds of frames you want. You can attach a button frame here and then set its click handlers however you wish.
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.
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.
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...
:) Thanks!
works great thanks for all the help, you rock!
Hi. As for the ace gui frame, make sure you are getting the actual frame object. I think it's something like:
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!
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