FiveM Docs
Core Resources

esx_menu_list

esx_menu_list reference for ESX Legacy. Show table menus with clickable row buttons via ESX.UI.Menu.Open('list'), the head/rows format, callbacks and pitfalls.

esx_menu_list renders a table menu: a header row and any number of data rows, with buttons inside cells. Use it to show tabular data the player can act on, such as a list of employees with "Promote" and "Fire" buttons. You open it with ESX.UI.Menu.Open('list', ...).

Overview

Resourceesx_menu_list
SideClient only
Menu typelist
Dependencieses_extended
UIjQuery + Mustache page in html/

The resource has no configuration file. The menu takes mouse focus about 200 ms after opening and releases it when the last list menu closes. If several list menus are open, only the most recently opened one is visible.

Opening a list menu

ESX.UI.Menu.Open('list', namespace, name, data, submit, cancel)
NameTypeDescription
namespacestringUsually GetCurrentResourceName().
namestringUnique menu name inside the namespace.
datatable{ head = {...}, rows = {...} }, see below.
submitfunction(data, menu)?A cell button was clicked.
cancelfunction(data, menu)?Escape was pressed.

The change and close arguments of ESX.UI.Menu.Open are accepted, but this menu type never sends change events. The returned menu object is described on the esx_menu_default page.

FieldTypeDescription
headstring[]Column headers. Escaped (shown as plain text).
rowstable[]One entry per row.
rows[i].colsstring[]Cell contents, one per column. Rendered as HTML.
rows[i].datatable?Any data you want back when a button in this row is clicked.

There is no title field; the table header is the only heading.

Buttons in cells

Inside a cell string, {{Label|value}} becomes a button. A cell can contain several buttons:

cols = { 'John Doe', 'Mechanic', '{{Promote|promote}} {{Fire|fire}}' }

Callback data

FieldDescription
data.valueThe value part of the clicked button.
data.dataThe data table of the clicked row, plus currentRow (1-based row index).
data._namespace, data._nameMenu identifiers.

cancel receives only _namespace and _name.

Example

client/main.lua
local function openEmployeeList(employees)
    local rows = {}

    for i = 1, #employees do
        local employee = employees[i]

        rows[#rows + 1] = {
            data = { identifier = employee.identifier },
            cols = {
                employee.name,
                employee.gradeLabel,
                '{{Promote|promote}} {{Fire|fire}}',
            },
        }
    end

    ESX.UI.Menu.Open('list', GetCurrentResourceName(), 'employees', {
        head = { 'Name', 'Grade', 'Actions' },
        rows = rows,
    }, function(data, menu)
        menu.close()
        TriggerServerEvent('my_boss:employeeAction', data.data.identifier, data.value)
    end, function(data, menu)
        menu.close()
    end)
end

Escape cell content

cols are inserted as raw HTML. If a cell shows player-controlled text (names, notes), strip < and > before you add it, or a player can inject markup into other players' menus.

Controls

KeyAction
Mouse click on a cell buttonSubmit
EscapeCancel (on the visible menu)

Common issues

  • Escape does nothing: you did not pass a cancel callback, or it does not call menu.close().
  • Button value has the wrong type: jQuery reads data-value and converts numeric strings to numbers, so {{Buy|5}} arrives as the number 5. Use string keys like buy_5 if you need consistent types.
  • | or }} in labels breaks buttons: the button syntax is parsed with a simple pattern. Keep labels free of these characters.

Frequently asked questions

Independent documentation

esx-fivem.com is a community project and is not affiliated with the ESX Framework team. Facts on this page were checked against the upstream source. Official resources: docs.esx-framework.org and github.com/esx-framework.
Edit on GitHub

Last updated on

On this page