lib-ScrollingTable

Need help?

  • 8 posts
  • on Thu, 09 Jul 2009 13:47:04

    Trying to use lib-st and need help?

  • 58 days later (on Sat, 05 Sep 2009 21:18:39)

    Hi,

    I've got the following table structure:

    	local columns =
    		{
    			{
    				["name"] = "Spieler",
    				["width"] = 150,
    				["sortnext"] = 2
    			},
    			{
    				["name"] = "DKP",
    				["width"] = 75,
    				["align"] = "RIGHT",
    				["defaultsort"] = "dsc",
    				["sortnext"] = 3
    			},
    			{
    				["name"] = "Preis",
    				["width"] = 75,
    				["align"] = "RIGHT"
    			}
    		};
    

    and want to sort it by the "DKP" column. A call to :SortData() does nothing. Do you have any idea what I'm doing wrong?

    Pelztier

  • 2 days later (on Tue, 08 Sep 2009 17:43:50)

    @Pelztier: Go

    whoaaaaaaaaaaaaaaa when did they turn on forum support globally?! sweet! I just replied to your PM. Sorry, I guess notifications are not working on the forums yet.

    edit: I'll put the PM contents here so other people who may run into this will have something to read.


    Did you override the onclick handler for the table?

    defaultsort is the default sort order for the column... which way you want to sort, up or down. It's mostly used to determine how to sort a secondary column.

    col.sort value is used to determine which column is under active sort. When you click a column header, it sets sort in the column you clicked. col.sort = col.defaultsort. if there is no defaultsort, it assumes "asc".

    If you want the dkp column to be sorted out of the box with no clicking, try

    {
    	["name"] = "DKP",
    	["width"] = 75,
    	["align"] = "RIGHT",
    	["defaultsort"] = "dsc",
    	["sort"] = "dsc",
    	["sortnext"] = 3
    },
    
    Last edited on 08 Sep 2009 by ddumont
  • 3 hours later (on Tue, 08 Sep 2009 21:28:13)

    Any chance you could post a real simple working sample? I did read that if you don't supply data, it will return a demo table. It's unclear to me what you do with the table to display it. (I will admit have haven't actually TRIED to use it yet.) I have worked with the WoW API and just can't seem to get a "table" to display. The visual part is my weakness. I program a lot, but don't do much GUI. This lib seems like it could save me a ton of work.

  • 5 hours later (on Wed, 09 Sep 2009 02:34:27)

    @Strawk: Go

    I can point you to the code in my dkp mod. I use the tables everywhere for dkp and loot displays. Would that help? It's more intermediate to advanced usage... but I think you'll get the idea.

  • 23 hours later (on Thu, 10 Sep 2009 01:37:18)

    This is the function in our mod that creates the data tables for the st-lib. Each "pool" is st-lib data. So..

    SDKPDATA["T7 Pool"]
    

    is an array of row data, I set the table with that data when I want to show the T7 pool in the table. The functions are various color functions or calculated columns that are defined within the mod itself. They are hooked up when the mod first loads.

    I used to have a working demo in the mod itself... but when I changed from a mod to a library I could no longer embed and reference the slash handlers using AceConsole... Let me dig up the code from the repo... I'm 90% sure it should still work with all the changes since...

    local ScrollingTable = LibStub("ScrollingTable");
    local cols = {
    	{
    		["name"] = "Test 1",
    	 	["width"] = 50,
    	 	["color"] = { ["r"] = 0.5, ["g"] = 0.5, ["b"] = 1.0, ["a"] = 1.0 },
    	}, -- [1]
    	{ 
    		["name"] = "Test 2", 
    		["width"] = 50, 
    		["align"] = "CENTER",
    		["bgcolor"] = { ["r"] = 1.0, ["g"] = 0.0, ["b"] = 0.0, ["a"] = 0.2 },
    	}, -- [2]
    	{ 
    		["name"] = "Test 3", 
    		["width"] = 50, 
    		["align"] = "RIGHT",
    		["bgcolor"] = { ["r"] = 0.0, ["g"] = 0.0, ["b"] = 0.0, ["a"] = 0.5 },
    	}, -- [3]
    };
    local st = ScrollingTable:CreateST(cols);
    local data = {}
    for row = 1, 20 do
    	if not data[row] then 
    		data[row] = {};
    	end
    	for col = 1, 3 do
    		if not data[row].cols then 
    			data[row].cols = {};
    		end
    		data[row].cols[col] = { ["value"] = math.random(50) };
    		-- data[row].cols[col].color    (cell text color)
    	end
    	-- data[row].color (row text color)
    end 
    data[5].cols[1].color = { ["r"] = 0.5, ["g"] = 1.0, ["b"] = 0.5, ["a"] = 1.0 };
    data[5].color = { ["r"] = 1.0, ["g"] = 0.5, ["b"] = 0.5, ["a"] = 1.0 };
    st:SetData(data);
    st:SetFilter(function(self, row)
    	return row.cols[1].value > 10; 
    end);
    

    Try something like that. I define a column structure for the library, and then i construct and set the data for it. The data is made up, buncha random numbers in a for loop.

  • 20 days later (on Wed, 30 Sep 2009 03:59:25)

    How do I keep a column from being sortable?

  • 8 hours later (on Wed, 30 Sep 2009 12:13:38)

    @evman182: Go

    you could override the onclick handler to return true if the click is on a header, false otherwise. see: here...

    Last edited on 30 Sep 2009 by ddumont
  • 8 posts

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