DgsGridListRemoveRow

From Multi Theft Auto: Wiki

This allows you to delete rows that exist in grid lists.

Syntax

bool dgsGridListRemoveRow ( element gridList, int rowIndex )

Required Arguments

  • gridList: The dgs grid list you want to remove a row from
  • rowIndex: The row ID which you want to remove

Returns

Returns true if the grid list row was successfully removed, false otherwise.

Example

In this example, when the script starts, a grid list with 1 column and 2 rows, which have text assigned to them. After 3 seconds, one row is randomly deleted.

DGS = exports.dgs
function deleteRow ()
        --Choose randomly which row to delete, output the
        --chosen row into the chat box, and delete the row
    	randomDeletion = math.random ( 1, 2 )   
	if randomDeletion == 1 then
		outputChatBox ( "Removing row A" )
		DGS:dgsGridListRemoveRow ( myGridList, rowA )
	elseif randomDeletion == 2 then    
		outputChatBox ( "Removing row B" )
		DGS:dgsGridListRemoveRow ( myGridList, rowB )
	end
end


function clientsideResourceStart ()
	--Create a gridlist
    	myGridList = DGS:dgsCreateGridList ( 0.30, 0.10, 0.5, 0.60, true ) 
    	--Create a column for myGridList to add rows into
        columnA = DGS:dgsGridListAddColumn ( myGridList, "columnA Title", 0.25 ) 
	--Create 2 rows for ColumnA and set the text for them
        rowA = DGS:dgsGridListAddRow ( myGridList )
	DGS:dgsGridListSetItemText ( myGridList, rowA, columnA, "Hello" )
	rowB = DGS:dgsGridListAddRow ( myGridList )
	DGS:dgsGridListSetItemText ( myGridList, rowB, columnA, "World!" )
   	--Trigger the function to delete a row 3 seconds after the script starts
        setTimer ( deleteRow, 3000, 1 )
end
addEventHandler ( "onClientResourceStart", resourceRoot, clientsideResourceStart )

See Also

Multi Language Supports

Animation

3D Interface

3D Text

Arrow List

Browser

Button

Check Box

Combo Box

Edit

Ellipse Detect Area

Detect Area

Grid List

Image

Memo

Label

Progress Bar

Radio Button

Scroll Bar

Scroll Pane

Switch Button

Tab Panel

Window

Plugin

Media Browser

Rounded Rectangle

Color Picker

Blur Box

Effect 3D