Thread Tools Display Modes
06-06-14, 12:23 AM   #1
Zanderwar
A Murloc Raider
Join Date: Jun 2014
Posts: 4
Help with working out a particular format

Hey guys, I'm using a library that generates a datagrid, the following code is working 100% UNTIL it comes to SetData. Long story short I'm obviously giving the data (a table) in the incorrect way.

Code:
playerGrid:SetPoint("TOPLEFT", mainWindow, "TOPLEFT", 20, 66)
playerGrid:SetPadding(1, 1, 1, 38)
playerGrid:SetHeadersVisible(true)
playerGrid:SetRowHeight(62)
playerGrid:SetRowMargin(2)
playerGrid:SetLayer(5)
playerGrid:SetHeight(510)
playerGrid:SetWidth(698)
playerGrid:SetUnselectedRowBackgroundColor({0.15, 0.1, 0.1, 1})
playerGrid:SetSelectedRowBackgroundColor({0.45, 0.3, 0.3, 1})	
playerGrid:AddColumn("item", "Player", SearchCellType, 80, 3, nil, "itemName")
playerGrid:AddColumn("level", "Level", "Text", 120, 1, "sellerName", true, { Alignment = "center" })
playerGrid:AddColumn("note", "Note", "Text", 300, 1, "sellerName", true, { Alignment = "center" })
playerGrid:SetOrder("item", false)
playerGrid:GetInternalContent():SetBackgroundColor(0, 0.05, 0.05, 0.5)
playerGrid:SetLoadingBarEnabled(true)

local values = {{	{ value = "one", key = 1},
			{ value = "two", key = 2},
			{ value = "three", key = 3}
			}} -- 1 row with 3 columns



playerGrid:SetData(values, nil, nil, true)
Everything is fine until it comes to SetData,



I can't for the life of me work out what format is needed to fill out the multiple columns.

I CAN add multiple rows with no problem but only the first column will be filled, the other 2 will say nil so its attempting to get the data somehow I'm just not giving it right.

I have attached DataGrid.lua to this post so please if you think you may have any idea on working out the format, please have a look
Attached Files
File Type: lua DataGrid.lua (28.7 KB, 155 views)
  Reply With Quote
06-06-14, 01:20 AM   #2
Zanderwar
A Murloc Raider
Join Date: Jun 2014
Posts: 4
With:

Code:
local values = 
{
    "Hello",
	"World",
}
This was the result:


So it leads me to believe that there is a string split but I can't find it
  Reply With Quote
06-06-14, 03:59 AM   #3
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Hi, uhh sorry but what game is this about? These forums are about WoW. :P
__________________
Grab your sword and fight the Horde!
  Reply With Quote
06-06-14, 06:57 AM   #4
Zanderwar
A Murloc Raider
Join Date: Jun 2014
Posts: 4
Originally Posted by Lombra View Post
Hi, uhh sorry but what game is this about? These forums are about WoW. :P
The game is RIFT, and I am aware of that however the question wasn't related to the game. I was asking if someone could help a fellow LuA coder about breaking down LuA syntax used to determine which string format is required.

Hope this is okay, thanks
  Reply With Quote
06-06-14, 07:30 AM   #5
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Well, I dunno. This isn't really a generic Lua thing. SetData is something specific to Rift, so knowing how Lua works doesn't really help here, and without knowing about the Rift API, all you can really do is guess.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
06-06-14, 08:20 AM   #6
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Try to change the table to:

Lua Code:
  1. local values = {    { value = "one", key = 1},
  2.             { value = "two", key = 2},
  3.             { value = "three", key = 3}
  4.             } -- 1 row with 3 columns
  Reply With Quote
06-06-14, 10:25 AM   #7
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
Whoever wrote this addon is insane, trying to trace a variable to actual data is just about impossible.

The only logical methods to write the data would be
Lua Code:
  1. local values = {
  2.     { item = 'One', level = '1', note = 'note' },
  3.     { item = 'Two', level = '2', note = 'note' },
  4.     { item = 'Three', level = '3', note = 'note' },
  5. }
Or
Lua Code:
  1. local values = {
  2.     { 'One', '1', 'note' },
  3.     { 'Two', '2', 'note' },
  4.     { 'Three', '3', 'note' },
  5. }

I would personally rather rewrite everything from scratch than try and figure out someone else's code in a script like this.
  Reply With Quote
06-06-14, 10:41 AM   #8
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Oh, my bad. Didn't realise SetData was defined in the addon. But yes, code looks very confusing.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
06-06-14, 11:06 AM   #9
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
The file appears to be from http://rift.curseforge.com/addons/yague, and while it claims to be "easy to use" it contains neither documentation nor comments, and it certainly isn't immediately obvious what format the data is supposed to be in, so I'm not convinced.
  Reply With Quote
06-06-14, 11:26 PM   #10
Zanderwar
A Murloc Raider
Join Date: Jun 2014
Posts: 4
Originally Posted by semlar View Post
Whoever wrote this addon is insane, trying to trace a variable to actual data is just about impossible.

The only logical methods to write the data would be
Lua Code:
  1. local values = {
  2.     { item = 'One', level = '1', note = 'note' },
  3.     { item = 'Two', level = '2', note = 'note' },
  4.     { item = 'Three', level = '3', note = 'note' },
  5. }
Or
Lua Code:
  1. local values = {
  2.     { 'One', '1', 'note' },
  3.     { 'Two', '2', 'note' },
  4.     { 'Three', '3', 'note' },
  5. }

I would personally rather rewrite everything from scratch than try and figure out someone else's code in a script like this.
Yes it's extremely messy, the first table you provided was the winner, thank you indefinitely for taking the time, really do appreciate it.

Unfortunately this library provides the only decent looking DataTable in the game, and I lack the experience to make my own sadly

Last edited by Zanderwar : 06-06-14 at 11:28 PM.
  Reply With Quote
06-07-14, 12:05 PM   #11
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
Originally Posted by Zanderwar View Post
[...]

Unfortunately this library provides the only decent looking DataTable in the game, and I lack the experience to make my own sadly
Did you take a look at http://www.wowace.com/addons/lib-st/ ?
  Reply With Quote
06-07-14, 02:50 PM   #12
repooc
A Deviate Faerie Dragon
AddOn Compiler - Click to view compilations
Join Date: Oct 2008
Posts: 10
Originally Posted by ravagernl View Post
Did you take a look at http://www.wowace.com/addons/lib-st/ ?
Thing is that lib u just linked is for wow and what the OP is working on is for rift if I read his post correctly.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Help with working out a particular format

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off