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
| Resource | esx_menu_list |
| Side | Client only |
| Menu type | list |
| Dependencies | es_extended |
| UI | jQuery + 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)| Name | Type | Description |
|---|---|---|
namespace | string | Usually GetCurrentResourceName(). |
name | string | Unique menu name inside the namespace. |
data | table | { head = {...}, rows = {...} }, see below. |
submit | function(data, menu)? | A cell button was clicked. |
cancel | function(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.
Menu data
| Field | Type | Description |
|---|---|---|
head | string[] | Column headers. Escaped (shown as plain text). |
rows | table[] | One entry per row. |
rows[i].cols | string[] | Cell contents, one per column. Rendered as HTML. |
rows[i].data | table? | 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
| Field | Description |
|---|---|
data.value | The value part of the clicked button. |
data.data | The data table of the clicked row, plus currentRow (1-based row index). |
data._namespace, data._name | Menu identifiers. |
cancel receives only _namespace and _name.
Example
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)
endEscape 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
| Key | Action |
|---|---|
| Mouse click on a cell button | Submit |
| Escape | Cancel (on the visible menu) |
Common issues
- Escape does nothing: you did not pass a
cancelcallback, or it does not callmenu.close(). - Button value has the wrong type: jQuery reads
data-valueand converts numeric strings to numbers, so{{Buy|5}}arrives as the number5. Use string keys likebuy_5if you need consistent types. |or}}in labels breaks buttons: the button syntax is parsed with a simple pattern. Keep labels free of these characters.
Related
Frequently asked questions
Independent documentation
Last updated on
esx_menu_dialog
esx_menu_dialog reference for ESX Legacy. Ask players for a text or number value with ESX.UI.Menu.Open('dialog'), data fields, callbacks and input rules.
esx_multicharacter
esx_multicharacter gives ESX Legacy players multiple characters per account. Config, slot commands, database tables, events and fixes for common errors.