GuiGridListClear: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
(7 intermediate revisions by 6 users not shown)
Line 1: Line 1:
__NOTOC__  
{{Client function}}
This function clears out all the data from a GUI grid list element
__NOTOC__
This function clears all the data from a grid list.


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool guiGridListClear ( element gridList )
bool guiGridListClear ( element gridList )
</syntaxhighlight>  
</syntaxhighlight>
{{OOP||[[Element/GUI/Gridlist|GuiGridList]]:clear}}


===Required Arguments===  
===Required Arguments===  
Line 11: Line 13:


===Returns===
===Returns===
Returns ''true'' if the grid list element is valid and it has been cleared successfully, ''false'' otherwise.
Returns ''true'' if the grid list element is valid and has been cleared successfully, ''false'' otherwise.


==Example==  
==Example==  
This example creates a grid list, puts a "Hello world" text in and clears it in 5 seconds
This creates a player list and then clears it when a button is clicked:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function test ()
-- create the grid list
--Create the grid list element
local playerList = guiCreateGridList(0.80, 0.40, 0.15, 0.35, true)
local testList = guiCreateGridList ( 0.45, 0.45, 0.10, 0.10, true )
guiGridListAddColumn(playerList, "#", 0.15)
--Create a column in the list and add a row with "Hello world" text
guiGridListAddColumn(playerList, "Player", 0.75)
local column = guiGridListAddColumn( testList, "test", 0.85 )
 
guiGridListSetItemText ( testList, guiGridListAddRow ( testList ), column, "Hello World", false, false )
-- fill the grid list with player names
--Set a timer to clear the grid list in 5 seconds
for index, player in ipairs(getElementsByType("player")) do
setTimer ( guiGridListClear, 5000, 1, testList )
    guiGridListAddRow(playerList, index, getPlayerName(player))
end
end
-- create a button to clear the grid list
local clearButton = guiCreateButton(0.80, 0.30, 0.15, 0.05, "Clear list", true)
-- when the button is clicked, clear the grid list
addEventHandler("onClientGUIClick", clearButton, function()
    guiGridListClear(playerList)
end)
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{GUI functions}}
{{GUI functions}}
{{GUI_events}}

Latest revision as of 17:47, 22 December 2022

This function clears all the data from a grid list.

Syntax

bool guiGridListClear ( element gridList )

OOP Syntax Help! I don't understand this!

Method: GuiGridList:clear(...)


Required Arguments

  • gridList: The grid list element to be cleared

Returns

Returns true if the grid list element is valid and has been cleared successfully, false otherwise.

Example

This creates a player list and then clears it when a button is clicked:

-- create the grid list
local playerList = guiCreateGridList(0.80, 0.40, 0.15, 0.35, true)
guiGridListAddColumn(playerList, "#", 0.15)
guiGridListAddColumn(playerList, "Player", 0.75)

-- fill the grid list with player names
for index, player in ipairs(getElementsByType("player")) do
    guiGridListAddRow(playerList, index, getPlayerName(player))
end

-- create a button to clear the grid list
local clearButton = guiCreateButton(0.80, 0.30, 0.15, 0.05, "Clear list", true)

-- when the button is clicked, clear the grid list
addEventHandler("onClientGUIClick", clearButton, function()
    guiGridListClear(playerList)
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