(2 Kb)
Updated: 07/19/15 06:29 PM
Update 7 (1.7.0)
Updated:07/19/15 06:29 PM
Created:07/19/15 06:24 PM
Monthly downloads:23
Total downloads:452
Version: 1
by: circonian [More]
What does it do?
It handles the basic code for creating a scrollList & updating the scrollList data for you.

Why did I write it?
I have no idea I found it laying around in a folder...I think I worked on to many addons with scrollLists & got sick of copy/pasting/editing code & figured a simple lib to just drop in the addons would be easier. But, over time I've seen many questions about scrollLists & although this lib does not do a lot of work for you, I thought it might be useful to those who don't know the necessary code to create a scrollList. The lib can drastically cut down on what you need to know to create a working scrollList...and if you need to you can copy the setupCallback, OnRowSelect, SortScrollList, & SetupDataRow functions from my examples below & then you really don't need to know anything.

How do I create a scrollList with it?
I will give two complete addon examples at the end of this post, first lets look at the individual pieces of code you need.

Load the Library
At the top of your code file load the library:
Lua Code:
  1. local libScroll = LibStub:GetLibrary("LibScroll")
Create the ScrollList
You will need to create a table containing the necessary information for initializing your scrollList. Below is an example containing all possible information you may include. Only the name, parent, & setupCallback are necessary, the rest are optional.

ScrollData table example:
Warning: Spoiler

Explanation of table items:
Warning: Spoiler

Then just call:
Lua Code:
  1. local scrollList = libScroll:CreateScrollList(scrollData)
Update the scrollList with your data
Create your table of dataItems to be loaded into the scrollList. Then just call Update and pass in your table:
Lua Code:
  1. scrollList:Update(dataItems)

dataItems table example:
The table for each individual data item can contain any data you want, this is only an example.
categoryId is optional, it is used to group items together in categories so you can show/hide groups of items by showing/hiding their categoryId.
Warning: Spoiler

That is all there is to it.

Available Functions:
scrollList:Clear() -- Clears all data from the scrollList
scrollList:Update (table dataItems) -- Pass in a table containing all of your data items for the scrollList to update the list with new data.

** Do note for the show/hide category functions to work the category values must be assigned to the scrollList by including them in the scrollData table that you pass to libScroll:CreateScrollList(scrollData) **
** Also these will only effect data items that have a categoryId assigned to them. As an example if you did not assign a categoryId to a data item & call HideAllCategories it will not be hidden **

scrollList:ShowAllCategories() -- Shows all data items that have a categoryId that matches one of the categories assigned to the scrollList. Data items that do not have a categoryId that matches one of the scrollList categories will not be effected.
scrollList:ShowOnlyCategory(integer categoryId) -- Shows only data items that have the given categoryId, all other data items are hidden (if they have a categoryId, items without a categoryId will not be effected).
scrollList:ShowCategory(integer categoryId) -- Shows data items that have the given categoryId.
scrollList:HideAllCategories() -- Hides all data items that have a categoryId that matches one of the categories assigned to the scrollList. Data items that do not have a categoryId that matches one of the scrollList categories will not be effected.
scrollList:HideCategory(integer categoryId) -- Hides data items that have the given categoryId.

A Complete (simple) example for creating a scrollList (no highlights, no select callbacks, & no sorting):
Warning: Spoiler

A Complete example with selection callbacks, row highlights, & a sorting function:
Warning: Spoiler
Post A Reply Comment Options
Unread 07/20/15, 08:02 AM  
AddOn Author - Click to view AddOns

Forum posts: 55
File comments: 79
Uploads: 2

LOL I guess you got tired of answering my questions about scrolllists =P

This will help someone greatly I am sure!
Report comment to moderator  
Reply With Quote
Post A Reply

Category Jump: