GuiGridListInsertRowAfter: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
(Fix incorrect return.)
 
(11 intermediate revisions by 9 users not shown)
Line 1: Line 1:
{{Client function}}
{{Client function}}
__NOTOC__
__NOTOC__
This allows you to insert a new row after a specified row. Good for inserting new rows in the middle of existing rows.
This allows you to insert a new row after a specified row, and simultaneously set text. Good for inserting new rows in the middle of existing rows. To insert at the top use -1 as row index.


==Syntax==  
==Syntax==  
Line 8: Line 8:
int guiGridListInsertRowAfter ( element gridList, int rowIndex )
int guiGridListInsertRowAfter ( element gridList, int rowIndex )
</syntaxhighlight>  
</syntaxhighlight>  
{{New feature/item|3.0153|1.5.3||
<syntaxhighlight lang="lua">
int guiGridListInsertRowAfter ( element gridList [, int rowIndex, int/string itemText1, int/string itemText2, ... ] )
</syntaxhighlight>
}}
{{OOP||[[Element/GUI/Gridlist|GuiGridList]]:insertRowAfter}}


===Required Arguments===  
===Required Arguments===  
*'''gridList:''' The grid list you want to add a row to
*'''gridList:''' The grid list you want to add a row to
*'''rowIndex:''' Row ID
*'''rowIndex:''' Row ID of the row you want to insert the '''new row''' after.
 
===Optional Arguments===
{{New feature/item|3.0153|1.5.3||
*'''itemText1:''' The text for the first column item in the row.  Either a string or a number can be passed (use numbers for sorting purposes).
*'''itemText2:''' The text for the second column item in the row.  Either a string or a number can be passed (use numbers for sorting purposes).
*'''...:''' Item text for any other columns
}}


===Returns===
===Returns===
Returns ''true'' if the row was successfully added, ''false'' otherwise.
Returns ''row id'' if the row was successfully added, ''false'' otherwise.


==Example==  
==Example==  
<!-- Explain what the example is in a single sentance -->
This example would create a gridlist then add the current players in the server and if anyone joins, it would insert a row at the bottom.
This example does...
<syntaxhighlight lang="lua">gridlist = guiCreateGridList(100,100,200,100,false)
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized -->
guiGridListAddColumn(gridlist,"Players",0.50)
<syntaxhighlight lang="lua">
for i,v in ipairs(getElementsByType("player"))do
--This line does...
guiGridListSetItemText(gridlist,guiGridListAddRow(gridlist),1,getPlayerName(v),false,false)
blabhalbalhb --abababa
end
--This line does this...
addEventHandler("onClientPlayerJoin",root,function()
mooo
guiGridListSetItemText(gridlist,guiGridListInsertRowAfter(gridlist,guiGridListGetRowCount(gridlist)),1,getPlayerName(source),false,false)--Add row at the bottom of the gridlist and name it the players name
end)
</syntaxhighlight>
</syntaxhighlight>


Line 30: Line 45:
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc -->
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc -->
{{GUI functions}}
{{GUI functions}}
[[Category:Incomplete]]
{{GUI_events}}

Latest revision as of 06:27, 16 January 2023

This allows you to insert a new row after a specified row, and simultaneously set text. Good for inserting new rows in the middle of existing rows. To insert at the top use -1 as row index.

Syntax

int guiGridListInsertRowAfter ( element gridList, int rowIndex )
int guiGridListInsertRowAfter ( element gridList [, int rowIndex, int/string itemText1, int/string itemText2, ... ] )

OOP Syntax Help! I don't understand this!

Method: GuiGridList:insertRowAfter(...)


Required Arguments

  • gridList: The grid list you want to add a row to
  • rowIndex: Row ID of the row you want to insert the new row after.

Optional Arguments

  • itemText1: The text for the first column item in the row. Either a string or a number can be passed (use numbers for sorting purposes).
  • itemText2: The text for the second column item in the row. Either a string or a number can be passed (use numbers for sorting purposes).
  • ...: Item text for any other columns

Returns

Returns row id if the row was successfully added, false otherwise.

Example

This example would create a gridlist then add the current players in the server and if anyone joins, it would insert a row at the bottom.

gridlist = guiCreateGridList(100,100,200,100,false)
guiGridListAddColumn(gridlist,"Players",0.50)
for i,v in ipairs(getElementsByType("player"))do
	guiGridListSetItemText(gridlist,guiGridListAddRow(gridlist),1,getPlayerName(v),false,false)
end
addEventHandler("onClientPlayerJoin",root,function()
	guiGridListSetItemText(gridlist,guiGridListInsertRowAfter(gridlist,guiGridListGetRowCount(gridlist)),1,getPlayerName(source),false,false)--Add row at the bottom of the gridlist and name it the players name
end)

See Also

General functions

Browsers

Buttons

Checkboxes

Comboboxes

Edit Boxes

Gridlists

Memos

Progressbars

Radio Buttons

Scrollbars

Scrollpanes

Static Images

Tab Panels

Tabs

Text Labels

Windows

Input

GUI