guiGridListIsSortingEnabled | Multi Theft Auto: Wiki Skip to content

guiGridListIsSortingEnabled

Client-side
Server-side
Shared

Pair: guiGridListSetSortingEnabled

This function checks whether the gridlist sorting is enabled or disabled.

OOP Syntax Help! I don't understand this!

  • Method:gui-gridlist:isSortingEnabled(...)
  • Variable: .sortingEnabled

Syntax

bool guiGridListIsSortingEnabled ( ​gui-gridlist guiGridlist )
Required arguments
  • guiGridlist: The GUI gridlist you wish to check if sorting is enabled or not.

Returns

Returns true if sorting is enabled, false otherwise. Returns nil if invalid gridlist element was passed.

  • bool: result

Code Examples

client

This example creates a gridlist with all server players and adds a command that enables and disables the gridlist sorting.

local newGridlist
addEventHandler("onClientResourceStart", resourceRoot, function()
-- Create the grid list element
newGridlist = guiCreateGridList(0.50, 0.50, 0.20, 0.30, true)
-- Create a new grid list
local column = guiGridListAddColumn(newGridlist, "Players", 0.85)
showCursor(true)
if (column) then -- If the column has been created, fill it with players
for id, player in ipairs(getElementsByType("player")) do
local row = guiGridListAddRow(newGridlist)
guiGridListSetItemText(newGridlist, row, column, getPlayerName(player), false, false)
end
end
end)
function toggleGridlistSortingState()
local newStatus = not guiGridListIsSortingEnabled(newGridlist)
outputChatBox("The gridlist sorting is now " .. (newStatus and "Enabled" or "Disabled"), 230, 230, 230)
guiGridListSetSortingEnabled(newGridlist, newStatus) -- Toggles the sorting for the gridlist
end
addCommandHandler("togglesorting", toggleGridlistSortingState)

See Also

GUI Functions