DgsGridListRemoveRow: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "{{Client function}} __NOTOC__ This allows you to delete rows that exist in grid lists. ==Syntax== <syntaxhighlight lang="lua"> bool dgsDxGridListRemoveRow ( element gridLis...")
 
No edit summary
Line 5: Line 5:
==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool dgsDxGridListRemoveRow ( element gridList, int rowIndex )
bool dgsGridListRemoveRow ( element gridList, int rowIndex )
</syntaxhighlight>  
</syntaxhighlight>  


Line 25: Line 25:
if randomDeletion == 1 then
if randomDeletion == 1 then
outputChatBox ( "Removing row A" )
outputChatBox ( "Removing row A" )
DGS:dgsDxGridListRemoveRow ( myGridList, rowA )
DGS:dgsGridListRemoveRow ( myGridList, rowA )
elseif randomDeletion == 2 then     
elseif randomDeletion == 2 then     
outputChatBox ( "Removing row B" )
outputChatBox ( "Removing row B" )
DGS:dgsDxGridListRemoveRow ( myGridList, rowB )
DGS:dgsGridListRemoveRow ( myGridList, rowB )
end
end
end
end
Line 35: Line 35:
function clientsideResourceStart ()
function clientsideResourceStart ()
--Create a gridlist
--Create a gridlist
     myGridList = DGS:dgsDxCreateGridList ( 0.30, 0.10, 0.5, 0.60, true )  
     myGridList = DGS:dgsCreateGridList ( 0.30, 0.10, 0.5, 0.60, true )  
     --Create a column for myGridList to add rows into
     --Create a column for myGridList to add rows into
         columnA = DGS:dgsDxGridListAddColumn ( myGridList, "columnA Title", 0.25 )  
         columnA = DGS:dgsGridListAddColumn ( myGridList, "columnA Title", 0.25 )  
--Create 2 rows for ColumnA and set the text for them
--Create 2 rows for ColumnA and set the text for them
         rowA = DGS:dgsDxGridListAddRow ( myGridList )
         rowA = DGS:dgsGridListAddRow ( myGridList )
DGS:dgsDxGridListSetItemText ( myGridList, rowA, columnA, "Hello" )
DGS:dgsGridListSetItemText ( myGridList, rowA, columnA, "Hello" )
rowB = DGS:dgsDxGridListAddRow ( myGridList )
rowB = DGS:dgsGridListAddRow ( myGridList )
DGS:dgsDxGridListSetItemText ( myGridList, rowB, columnA, "World!" )
DGS:dgsGridListSetItemText ( myGridList, rowB, columnA, "World!" )
   --Trigger the function to delete a row 3 seconds after the script starts
   --Trigger the function to delete a row 3 seconds after the script starts
         setTimer ( deleteRow, 3000, 1 )
         setTimer ( deleteRow, 3000, 1 )

Revision as of 13:46, 18 January 2018

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

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