Info from table to DListView

I have a table and the ability to insert info into that table with the proper derma, but I don’t know how to get info from from the table to a DListView. I have the list, and when I try to do something like:


for k, v in pairs(myowntable)do
	list:AddLine( v[1], v[2], v[3] )
	list:SortByColumn( 3, true )
end

but all that does it put up random letters into each area. I know it has something to do with net.SendToServer and net.Recieve but I have absolutely no idea how to go about doing it. Any help would be fantastic!

Show rest of the code.



for k, v in pairs(myowntable)do


Cycles through every line of ‘myowntable’, right? Doesn’t that mean that if you say



list:AddLine( v[1], v[2], v[3] )


You are saying ‘Get lines 1, 2 and 3 from line 1 of myowntable’?

To do list:AddLine( v[1], v[2], v[3] )

You would need a table like this:



mytable = {
{"wow!","wowser!","wowowow"}
}
v[1] = wow!, v[2] = wowser!, v[3] = wowowow


To get the lines 1,2 and 3 you would do:


mytable = {
"first",
"second",
"third"
}
mytable[1] = first, mytable[2] = second, mytable[3] = third



Edit: Post more code if you want a fix for your specific problem

Let’s say this is your table.
[Lua]
local myowntable = { “Hello”, " How", “Are”, " You" }
[/lua]

When you do
[Lua]for k,v in pairs( myowntable ) do[/lua]
Your telling the program that for each entry in your table, assign the value of the key to k, and the value of the value to v. After the do everything is ran, then depending on the amount of times it has been ran it goes back to the top, reassaigns the variables and starts again. We can show this by doing this:
[Lua]
for k,v in pairs( myowntable ) do
print( k, v )
end
[/lua]
This will give us an output of this:
[lua]
1 Hello
2 How
3 Are
4 You
[/lua]
If we only wanted to access a specific key in the table where we knew what the key was, we would do this
[lua]
myowntable[ 1 ]
[/lua]
That would return “Hello”

When I first looked at this I was so confused. Then I realized your = at the bottom were meant to be == and that it isn’t meant to be proper code.

I appreciate your attempt to help though, next time be more clear with your post, like the one above me. Beautiful example of how you should format your replies to questions like this.

Well, I am really grateful for your guys` help, but before you guys posted I had already played around with it so much that I figured it out. I should have closed the thread… I am working on a report system and I managed to get all the info from my table into the DListView. Now I have hit other issues that might need their own thread, unless you guys can help me out here. But here is what finally got it:
[LUA]
for _, report in pairs(myowntable)do
list:AddLine( report.REPORTER, report.VIOLATOR, report.RULEBROKEN, report.DATE, report.ID )
list:SortByColumn( 4, true )
end
[/LUA]
Now I am working on when you right click it, to click, “View full description” then it shows the rest of the information. But I can’t figure out how to get the information just from that single line. I think I am going to make a new thread for this because this has really stumped me…

DListView:AddLine returns the line that is added as a vgui element. What you can do is this:
[lua]
local line = list:AddLine( “Swiggity Swooty” )
line.Desc = “Commin’ for dat booty”
[/lua]
Then this:
[lua]
DListView.OnRowRightClick = function( self, lineIndex, line )
print( line.Desc )
end
[/lua]

Meharryp, I appreciate you trying, but I still don’t know how to link that line with the correct table. Look at the full post I made here http://forum.facepunch.com/showthread.php?t=1459169