DgsGridListSetItemData: Difference between revisions

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


This function sets a Item Data associated to a grid list item.
This function sets a Item Data associated to a grid list item.
 
{{Note|This function can work before you set the item's text using  [[dgsGridListSetItemData]] Different from  [[guiGridListSetItemData]] .}}
{{Note|This function can work before you set the item's text using  [[dgsDxGridListSetItemText]] ! Different from  [[guiGridListSetItemData]] .}}


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool dgsDxGridListSetItemData ( element gridList, int rowIndex, int columnIndex, var data )
bool dgsGridListSetItemData ( element gridList, int rowIndex, int columnIndex, var data )
</syntaxhighlight>  
</syntaxhighlight>  


Line 24: Line 23:
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) ^ 100 ) )
         DGS:dgsDxGridListSetItemData ( numberList, row, column, "Test" )
         DGS:dgsGridListSetItemData ( numberList, row, column, "Test" )
         local myItemData = DGS:dgsDxGridListGetItemData ( numberList, row, column )
         local myItemData = DGS:dgsGridListGetItemData ( numberList, row, column )
         outputChatBox ( "My gridlist item data: " .. myItemData )
         outputChatBox ( "My gridlist item data: " .. myItemData )
     end
     end
Line 37: Line 36:
</syntaxhighlight>
</syntaxhighlight>


==Syntax==
<syntaxhighlight lang="lua">
bool dgsGridListSetItemData ( element gridList, int rowIndex, int columnIndex, mixed key, mixed data )
</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 key you wish to store the data under.
*'''data:'''  The value you wish to store.
===Returns===
Returns '''true''' if set successfully, ''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) ^ 100 ) )
        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 )
</syntaxhighlight>
==See Also==
==See Also==
{{DGSFUNCTIONS}}
{{DGSFUNCTIONS}}

Latest revision as of 11:21, 27 January 2021

This function sets a Item Data associated to a grid list item.

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

Syntax

bool dgsGridListSetItemData ( element gridList, int rowIndex, int columnIndex, var data )

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.
  • data: the data you want to set.

Returns

Returns true if set successfully, 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) ^ 100 ) )
        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

bool dgsGridListSetItemData ( element gridList, int rowIndex, int columnIndex, mixed key, mixed data )

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 key you wish to store the data under.
  • data: The value you wish to store.

Returns

Returns true if set successfully, 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) ^ 100 ) )
        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