GuiGridListGetItemData: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 18: Line 18:
==Example==  
==Example==  
<!-- Explain what the example is in a single sentance -->
<!-- Explain what the example is in a single sentance -->
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 -->
This example displays a random item data from the gridlist
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">function clientsideResourceStart ()
--This line does...
    local numberList = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true )
blabhalbalhb --abababa
    local column = guiGridListAddColumn( numberList, "Column Title", 0.85 )
--This line does this...
    if ( column ) then
mooo
        row = guiGridListAddRow ( numberList )
        myItem = guiGridListSetItemText ( numberList, row, column, tostring(math.random(0, 10) ^ 100), false, false )
        myItemData = guiGridListGetItemData ( numberList, row, column )
outputChatBox ( "My gridlist item data: "..myItemData )
    end
end
addEventHandler ( "onClientResourceStart", getRootElement(), clientsideResourceStart )
</syntaxhighlight>
</syntaxhighlight>



Revision as of 06:14, 8 October 2007

With this function you can retrieve the string data associated with an item in a grid list. This is not the text that is displayed on the item, but an internal string that you can use to hold extra information about the item.

Syntax

string guiGridListGetItemData ( element gridList, int rowIndex, int columnIndex )

Required Arguments

  • gridList: the grid list containing the item you're interested in
  • rowIndex: the row index of the item
  • columnIndex: the column index of the item

Returns

Returns a string with the item data of the specified item if succesful, false if one of the arguments was invalid.

Example

This example displays a random item data from the gridlist

function clientsideResourceStart ()
    local numberList = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true )
    local column = guiGridListAddColumn( numberList, "Column Title", 0.85 )
    if ( column ) then
        row = guiGridListAddRow ( numberList )
        myItem = guiGridListSetItemText ( numberList, row, column, tostring(math.random(0, 10) ^ 100), false, false )
        myItemData = guiGridListGetItemData ( numberList, row, column )
		outputChatBox ( "My gridlist item data: "..myItemData )
    end
end
addEventHandler ( "onClientResourceStart", getRootElement(), 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