DgsGridListGetSelectedItems

From Multi Theft Auto: Wiki
Revision as of 07:37, 11 July 2019 by Thisdp (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This function returns the items selected in the specified dgs grid list.

Note that the index of row and column start from 1, which is different from guiGridListGetSelectedItems.

Syntax

table dgsGridListGetSelectedItems ( element gridList )

Required Arguments

  • gridList: The dgs grid list which selected items you want to retrieve.

Returns

Returns a table over the selected items in the dgs grid list in this format ( the same as cegui's ) :

table = {
    [1] = {
        ["column"], -- has the first selected item's column ID
        ["row"] -- has the first selected item's row ID
    },
    [2] = {
        ["column"],-- has the second selected item's column ID
        ["row"] -- has the second selected item's row ID
    },
    ...
}


if everything was successful or false if invalid arguments were passed.

Example

DGS = exports.dgs
-- This example creates a grid list of all players, clicking "Selected" button will then use dgsGridListGetSelectedItems to show all selected items.
playerWindow = DGS:dgsCreateWindow(526, 230, 291, 284, "", false)
gridlistPlayers = DGS:dgsCreateGridList(9, 23, 272, 201, false, playerWindow)
DGS:dgsGridListAddColumn(gridlistPlayers, "Players", 0.9)
DGS:dgsGridListSetSelectionMode(gridlistPlayers, 1) -- So can select many players
for _, players in ipairs(getElementsByType("player")) do 
	local row = DGS:dgsGridListAddRow(gridlistPlayers)
	DGS:dgsGridListSetItemText(gridlistPlayers, row, 1, getPlayerName(players))
end 
buttonSelectedPlayer = DGS:dgsCreateButton(9, 227, 272, 20, "Selected", false, playerWindow)

function seeSelected()
	local selected = DGS:dgsGridListGetSelectedItems(gridlistPlayers)
	for i, data in ipairs(selected) do -- Loops through all selected items
		outputChatBox(DGS:dgsGridListGetItemText(gridlistPlayers, data["row"], 1)) -- Shows player name of selected players
	end
end
addEventHandler("onDgsMouseClick", buttonSelectedPlayer, seeSelected, false)

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