DgsGridListGetItemData: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
(15 intermediate revisions by 3 users not shown)
Line 2: Line 2:


With this function you can retrieve the [[string]] data associated with an item in a dgs 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.<br/>
With this function you can retrieve the [[string]] data associated with an item in a dgs 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.<br/>
'''Note:''' This function will '''can work before''' you set the item's text using [[dgsDxGridListSetItemText]]! Different from [[guiGridListGetItemData]].
{{Note|This function can work before you set the item's text using [[dgsGridListSetItemData]] ! Different from [[guiGridListGetItemData]] .}}


==Syntax==  
==Syntax 1==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
var dgsDxGridListGetItemData ( element gridList, int rowIndex, int columnIndex )
var dgsGridListGetItemData ( element gridList, int rowIndex, int columnIndex )
</syntaxhighlight>  
</syntaxhighlight>  


Line 15: Line 15:


===Returns===
===Returns===
Returns the item data of the specified item if succesful, ''false'' if one of the arguments was invalid.
Returns the item data of the specified item if successful, ''false'' if one of the arguments was invalid.


==Example==
==Example==
Line 22: Line 22:
DGS = exports.dgs
DGS = exports.dgs
function clientsideResourceStart ()
function clientsideResourceStart ()
     local numberList = DGS:dgsDxCreateGridList ( 0.80, 0.10, 0.15, 0.60, true )
     local numberList = DGS:dgsCreateGridList ( 0.80, 0.10, 0.15, 0.60, true )
     local column = DGS:dgsDxGridListAddColumn ( numberList, "Column Title", 0.85 )
     local column = DGS:dgsGridListAddColumn ( numberList, "Column Title", 0.85 )
     if ( column ) then
     if ( column ) then
         local row = DGS:dgsDxGridListAddRow ( numberList )
         local row = DGS:dgsGridListAddRow ( numberList )
         local myItem = DGS:dgsDxGridListSetItemText ( numberList, row, column, tostring( math.random(0, 10) ^ 100 ), false, false )
         local myItem = DGS:dgsGridListSetItemText ( numberList, row, column, tostring( math.random(0, 10) )
         local myItemData = DGS:dgsDxGridListGetItemData ( numberList, row, column )
        DGS:dgsGridListSetItemData ( numberList, row, column, "Test" )
        local myItemData = DGS:dgsGridListGetItemData ( numberList, row, column )
        outputChatBox ( "My gridlist item data: " .. myItemData )
    end
end
addEventHandler ( "onClientResourceStart", resourceRoot, clientsideResourceStart )
</syntaxhighlight>
 
 
==Syntax 2==
<syntaxhighlight lang="lua">
var dgsGridListGetItemData ( element gridList, int rowIndex, int columnIndex, mixed key )
</syntaxhighlight>
 
===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
*'''key:''' The name of the item data entry you want to retrieve.
 
===Returns===
Returns the item data of the specified item if successful, ''false'' if one of the arguments was invalid.
 
==Example==
This example displays a random item data from the gridlist.
<syntaxhighlight lang="lua">
DGS = exports.dgs
function clientsideResourceStart ()
    local numberList = DGS:dgsCreateGridList ( 0.80, 0.10, 0.15, 0.60, true )
    local column = DGS:dgsGridListAddColumn ( numberList, "Column Title", 0.85 )
    if ( column ) then
        local row = DGS:dgsGridListAddRow ( numberList )
        local myItem = DGS:dgsGridListSetItemText ( numberList, row, column, tostring( math.random(0, 10) ) )
        DGS:dgsGridListSetItemData ( numberList, row, column, "myKey", "test" )
         local myItemData = DGS:dgsGridListGetItemData ( numberList, row, column, "myKey" )
         outputChatBox ( "My gridlist item data: " .. myItemData )
         outputChatBox ( "My gridlist item data: " .. myItemData )
     end
     end

Latest revision as of 11:24, 27 July 2023

With this function you can retrieve the string data associated with an item in a dgs 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.

[[{{{image}}}|link=|]] Note: This function can work before you set the item's text using dgsGridListSetItemData ! Different from guiGridListGetItemData .

Syntax 1

var dgsGridListGetItemData ( 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 the item data of the specified item if successful, false if one of the arguments was invalid.

Example

This example displays a random item data from the gridlist.

DGS = exports.dgs
function clientsideResourceStart ()
    local numberList = DGS:dgsCreateGridList ( 0.80, 0.10, 0.15, 0.60, true )
    local column = DGS:dgsGridListAddColumn ( numberList, "Column Title", 0.85 )
    if ( column ) then
        local row = DGS:dgsGridListAddRow ( numberList )
        local myItem = DGS:dgsGridListSetItemText ( numberList, row, column, tostring( math.random(0, 10) )
        DGS:dgsGridListSetItemData ( numberList, row, column, "Test" )
        local myItemData = DGS:dgsGridListGetItemData ( numberList, row, column )
        outputChatBox ( "My gridlist item data: " .. myItemData )
    end
end
addEventHandler ( "onClientResourceStart", resourceRoot, clientsideResourceStart )


Syntax 2

var dgsGridListGetItemData ( element gridList, int rowIndex, int columnIndex, mixed key )

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
  • key: The name of the item data entry you want to retrieve.

Returns

Returns the item data of the specified item if successful, false if one of the arguments was invalid.

Example

This example displays a random item data from the gridlist.

DGS = exports.dgs
function clientsideResourceStart ()
    local numberList = DGS:dgsCreateGridList ( 0.80, 0.10, 0.15, 0.60, true )
    local column = DGS:dgsGridListAddColumn ( numberList, "Column Title", 0.85 )
    if ( column ) then
        local row = DGS:dgsGridListAddRow ( numberList )
        local myItem = DGS:dgsGridListSetItemText ( numberList, row, column, tostring( math.random(0, 10) ) )
        DGS:dgsGridListSetItemData ( numberList, row, column, "myKey", "test" )
        local myItemData = DGS:dgsGridListGetItemData ( numberList, row, column, "myKey" )
        outputChatBox ( "My gridlist item data: " .. myItemData )
    end
end
addEventHandler ( "onClientResourceStart", resourceRoot, clientsideResourceStart )

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