DgsGridListAddColumn: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
(7 intermediate revisions by the same user not shown)
Line 5: Line 5:
==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
int dgsDxGridListAddColumn ( element gridList, string title, float width )
int dgsGridListAddColumn ( element gridList, string title, float width [, int insertPosition = nil, string horizontalAlign = "left" ] )
</syntaxhighlight>  
</syntaxhighlight>  


Line 12: Line 12:
*'''title:''' Title of the column
*'''title:''' Title of the column
*'''width:''' Column width, relative to the grid list width
*'''width:''' Column width, relative to the grid list width
===Optional Arguments===
*'''insertPosition:''' The position you want to insert to, after the last column by default.
*'''horizontalAlign:''' Column text horizontal alignment ( also affects row text ).


===Returns===
===Returns===
Line 17: Line 21:


==Example==  
==Example==  
<section name="Client" class="client" show="true">
'''Example 1:'''
This example creates a player list on the right side of the screen and fills it with the currently connected players.
This example creates a player list on the right side of the screen and fills it with the currently connected players.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
DGS = exports.dgs
DGS = exports.dgs
function clientsideResourceStart ()
function clientsideResourceStart ()
local playerList = DGS:dgsDxCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) -- Create the grid list
local playerList = DGS:dgsCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) -- Create the grid list
local column = DGS:dgsDxGridListAddColumn( playerList, "Player", 0.85 ) -- Create a 'players' column in the list
local column = DGS:dgsGridListAddColumn( playerList, "Player", 0.85 ) -- Create a 'players' column in the list
if ( column ) then -- If the column was successfully created
if ( column ) then -- If the column was successfully created
for id, playeritem in ipairs(getElementsByType("player")) do  
for id, playeritem in ipairs(getElementsByType("player")) do  
--Loop through all the players, adding them to the table
--Loop through all the players, adding them to the table
local row = DGS:dgsDxGridListAddRow ( playerList )
local row = DGS:dgsGridListAddRow ( playerList )
DGS:dgsDxGridListSetItemText ( playerList, row, column, getPlayerName ( playeritem ), false, false )
DGS:dgsGridListSetItemText ( playerList, row, column, getPlayerName ( playeritem ) )
end
end
end
end
Line 33: Line 39:
addEventHandler ( "onClientResourceStart", resourceRoot, clientsideResourceStart )
addEventHandler ( "onClientResourceStart", resourceRoot, clientsideResourceStart )
</syntaxhighlight>
</syntaxhighlight>
</section>


<section name="Client" class="client" show="false">
<section name="Client" class="client" show="true">
'''Example 2:'''  
'''Example 2:'''  


<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua" >
DGS = exports.dgs
DGS = exports.dgs
gridlist  = DGS:dgsDxCreateGridList (367, 120, 362, 489, false)
gridlist  = DGS:dgsCreateGridList (367, 120, 362, 489, false)
addCommandHandler("add",function (commandName,arg)
addCommandHandler("add",function (commandName,arg)
if arg ~= "" then  
if arg ~= "" then  
DGS:dgsDxGridListAddColumn(gridlist,arg, 0.5)     
DGS:dgsGridListAddColumn(gridlist,arg, 0.5)     
end  
end  
end)
end)

Latest revision as of 07:59, 20 June 2018

This function is used to create columns in grid lists.

Syntax

int dgsGridListAddColumn ( element gridList, string title, float width [, int insertPosition = nil, string horizontalAlign = "left" ] )

Required Arguments

  • gridList: The grid list you want to add a column to
  • title: Title of the column
  • width: Column width, relative to the grid list width

Optional Arguments

  • insertPosition: The position you want to insert to, after the last column by default.
  • horizontalAlign: Column text horizontal alignment ( also affects row text ).

Returns

Returns the column id if it was created, false otherwise.

Example

Click to collapse [-]
Client

Example 1: This example creates a player list on the right side of the screen and fills it with the currently connected players.

DGS = exports.dgs
function clientsideResourceStart ()
	local playerList = DGS:dgsCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) -- Create the grid list
	local column = DGS:dgsGridListAddColumn( playerList, "Player", 0.85 ) -- Create a 'players' column in the list
	if ( column ) then -- If the column was successfully created
		for id, playeritem in ipairs(getElementsByType("player")) do 
		--Loop through all the players, adding them to the table
			local row = DGS:dgsGridListAddRow ( playerList )
			DGS:dgsGridListSetItemText ( playerList, row, column, getPlayerName ( playeritem ) )
		end
	end
end
addEventHandler ( "onClientResourceStart", resourceRoot, clientsideResourceStart )
Click to collapse [-]
Client

Example 2:

DGS = exports.dgs
gridlist  = DGS:dgsCreateGridList (367, 120, 362, 489, false)
addCommandHandler("add",function (commandName,arg)
	if arg ~= "" then 
		DGS:dgsGridListAddColumn(gridlist,arg, 0.5)    
	end 
end)

See Also

Custom Cursor Functions

Multi Language Supports

Animation

3D Element

3D Interface

3D Line

3D Image

3D Text

Browser

Button

Check Box

Combo Box

Custom Renderer

Edit

Detect Area

Drag'N Drop

Grid List

Image

Memo

Menu

Label

Layout

Line

Progress Bar

Radio Button

Scale Pane

Scroll Bar

Scroll Pane

Selector

Style

Switch Button

Tab Panel

Window

Basic Shape Plugins

Circle

Quadrilateral

Rounded Rectangle

Other Plugins

Blur Box

Canvas

Chart

Color Picker

Effect 3D

Gradient

Mask

Media Browser

Nine Slice

Object Preview Supports

Paste Handler

QRCode

Remote Image

Screen Source

SVG

Tooltips