GuiGridListSetItemText: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
(OOP syntax)
 
(13 intermediate revisions by 11 users not shown)
Line 1: Line 1:
__NOTOC__  
{{Client function}}
<!-- Describe in plain english what this function does. Don't go into details, just give an overview -->
__NOTOC__
This fake function is for use with blah & blah and does blahblahblabhalbhl
This function changes the text of a gridlist item.
 
Notice: This function doesn't work well with Sorting. If you are using sorting, please use the optional arguments of [[guiGridListAddRow]] as much as possible.


==Syntax==  
==Syntax==  
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd -->
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
returnType functionName ( arguments )
bool guiGridListSetItemText ( element gridList, int rowIndex, int columnIndex, string text, bool section, bool number )
</syntaxhighlight>  
</syntaxhighlight>
{{OOP||[[Element/GUI/Gridlist|GuiGridList]]:setItemText}}


===Required Arguments===  
===Required Arguments===  
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type -->
*'''gridList:''' The grid list element
*'''argumentName:''' description
*'''rowIndex:''' Row ID
 
*'''columnIndex:''' Column ID
<!-- Only include this section below if there are optional arguments -->
*'''text:''' The text you want to put in (does NOT accept numbers, use tostring() for that)
===Optional Arguments===
*'''section:''' Determines if the item is a section
{{OptionalArg}}
*'''number:''' Tells whether the text item is a number value or not (used for sorting)
*'''argumentName2:''' description
*'''argumentName3:''' description


===Returns===
===Returns===
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check -->
Returns ''true'' if the item text was set successfully, ''false'' otherwise.
Returns ''true'' if blah, ''false'' otherwise.


==Example==  
==Example==  
<!-- Explain what the example is in a single sentance -->
This example creates a player list on the right of the screen and fills it
This example does...
<!-- 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 -->
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--This line does...
function clientsideResourceStart ()
blabhalbalhb --abababa
        local playerList = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) -- Create the grid list
--This line does this...
        local column = guiGridListAddColumn( playerList, "Player", 0.85 ) -- Create a 'players' column in the list
mooo
        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 = guiGridListAddRow ( playerList )
                        guiGridListSetItemText ( playerList, row, column, getPlayerName ( playeritem ), false, false )
                end
        end
end
addEventHandler ( "onClientResourceStart", getResourceRootElement(), clientsideResourceStart )
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
<!-- 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 21:14, 7 November 2018

This function changes the text of a gridlist item.

Notice: This function doesn't work well with Sorting. If you are using sorting, please use the optional arguments of guiGridListAddRow as much as possible.

Syntax

bool guiGridListSetItemText ( element gridList, int rowIndex, int columnIndex, string text, bool section, bool number )

OOP Syntax Help! I don't understand this!

Method: GuiGridList:setItemText(...)


Required Arguments

  • gridList: The grid list element
  • rowIndex: Row ID
  • columnIndex: Column ID
  • text: The text you want to put in (does NOT accept numbers, use tostring() for that)
  • section: Determines if the item is a section
  • number: Tells whether the text item is a number value or not (used for sorting)

Returns

Returns true if the item text was set successfully, false otherwise.

Example

This example creates a player list on the right of the screen and fills it

function clientsideResourceStart ()
        local playerList = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) -- Create the grid list
        local column = guiGridListAddColumn( 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 = guiGridListAddRow ( playerList )
                        guiGridListSetItemText ( playerList, row, column, getPlayerName ( playeritem ), false, false )
                end
        end
end
addEventHandler ( "onClientResourceStart", getResourceRootElement(), clientsideResourceStart )

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