DListView - ply data per line?

I made a list using DListView, it prints all players currently in-game with steam id.

My question is, I made a right click menu, how would I get the ply: data so I could have it execute commands like ply:kick

I know there’s a few errors in my code, but right now I’m just focusing on how to pull each players ply: info


	local playerList = vgui.Create( "DListView", panelLeft )
	playerList:SetTall( 680 )
	playerList:DockMargin( 10, 10, 10, 10 )
	playerList:Dock( TOP )
	playerList:SetMultiSelect( false )
	playerList:AddColumn ( "Name" )
	playerList:AddColumn ( "SteamID32" )
	playerList.Paint = function( self, w, h )
		DrawBlurPanel( self )
		draw.RoundedBox( 4,0,0,w,h,Color( 0,0,0,200 ) )
	end

	for k, v in pairs( playerList["Columns"] ) do
		v.Header.Paint = function(self, w, h) draw.RoundedBox( 4,0,0,w,h,Color( 100,0,0,255 ) ) end
		v.Header:SetTextColor( color_white )
	end

	function playerList:OnRowSelected( row ) 
		local ban = self:GetLine( row ).ban
	end

	function playerList:OnRowRightClick( row )
		local PlayerlistMenu = DermaMenu( )
		local selectedDbId = self:GetLine( row )
		PlayerlistMenu:AddOption( "Kick", function( ) 
			ply:Kick( "Goodbye" )
			self:RemoveLine( row )
		end )

		PlayerlistMenu:Open( )

	end

	function playerList:Rehash( )
		
		self:Clear( )
		for k, v in pairs(player.GetAll()) do
			local row = playerList:AddLine( v:Name(), v:SteamID() )
			
			function row:GetColumnText( i )

				return self.Columns* and self.Columns*.value or ""

			end

			function row:Paint( w, h )

				self:SizeToContents( )
				SetRowColor = Color( 0, 0, 0, 150 )
				
				if self:IsLineSelected( ) then
					surface.SetDrawColor( 0, 0, 0, 190 )
					surface.DrawRect( 0, 0, self:GetWide( ), self:GetTall( ) )
					surface.SetDrawColor( Color( 0, 0, 0, 190 ) )
					surface.DrawRect( 2, 2, self:GetWide( ) - 4, self:GetTall( ) - 4 )
					surface.SetTextColor( 255, 255, 255, 255 )
				else
					surface.SetDrawColor( SetRowColor )
					surface.DrawRect( 0, 0, self:GetWide( ), self:GetTall( ) )
					surface.SetTextColor( 255, 255, 255, 255 )
				end
			end
		end
		if not selectedItem then 
			self:SelectFirstItem( ) 
		else
			self:SelectItem( selectedItem )
		end
	end

	playerList:Rehash( )
	LocalPlayer( ).playerList = playerList



Any help would be great! thanks!

Under:


local row = playerList:AddLine( v:Name(), v:SteamID() )

Add:


row.player = v

Then you can execute code by getting active row and running it’s key - activeRow.player

Thanks Neth. I got it returning properly when I print (v) now. I don’t know why I didn’t think of that. But where my confusion is, is that my menu is sitting in another function. I can still call “v” though as long as it’s not a local variable right? and for each player is a different key, so would I use something like * for the key and loop through?

Modified the code a bit - still getting nil on kick() though