Example
|
---|
'columns' => [ 'TITLE' => 'Create animation for adding a new element to grid', 'DATE' => '15 September 2022, 14:51', 'AUTHOR' => 'John Smith', 'TAGS' => [ 'addButton' => [ 'events' => [ 'click' => 'console.log.bind(null, "add button click")', ], ], 'items' => [ [ 'text' => 'Grid', 'active' => false, 'events' => [ 'click' => 'console.log.bind(null, "tag click")', ], 'removeButton' => [ 'events' => [ 'click' => 'console.log.bind(null, "tag remove click")', ], ], ], [ 'text' => 'UI', 'active' => false, 'events' => [ 'click' => 'console.log.bind(null, "tag click")', ], 'removeButton' => [ 'events' => [ 'click' => 'console.log.bind(null, "tag remove click")', ], ], ], [ 'text' => 'Animation', 'active' => true, 'events' => [ 'click' => 'console.log.bind(null, "tag click")', ], 'removeButton' => [ 'events' => [ 'click' => 'console.log.bind(null, "tag remove click")', ], ], ], [ 'text' => 'Main', 'active' => false, 'events' => [ 'click' => 'console.log.bind(null, "tag click")', ], 'removeButton' => [ 'events' => [ 'click' => 'console.log.bind(null, "tag remove click")', ], ], ] ], ], 'LABELS' => [ [ 'text' => 'Lable #1', 'color' => \Bitrix\Main\Grid\Cell\Label\Color::DANGER, 'events' => [ 'click' => "console.log.bind(null, 'Label click')", ], 'removeButton' => [ 'type' => \Bitrix\Main\Grid\Cell\Label\RemoveButtonType::INSIDE, 'events' => [ 'click' => "console.log.bind(null, 'Label remove click')", ], ], ], [ 'text' => 'Lable #2', 'color' => \Bitrix\Main\Grid\Cell\Label\Color::PRIMARY, 'events' => [ 'click' => "console.log", ], 'removeButton' => [ 'type' => \Bitrix\Main\Grid\Cell\Label\RemoveButtonType::OUTSIDE, 'events' => [ 'click' => "console.log.bind(null, 'Label remove click')", ], ], ], [ 'text' => 'Lable #3', 'color' => \Bitrix\Main\Grid\Cell\Label\Color::SECONDARY, 'events' => [ 'click' => "console.log", ], 'remove-button-events' => [ 'click' => "console.log.bind(null, 'remove')", ], ], [ 'text' => '«Text»', 'color' => \Bitrix\Main\Grid\Cell\Label\Color::LIGHT, 'events' => [ 'click' => "console.log", ], 'remove-button-events' => [ 'click' => "console.log.bind(null, 'remove')", ], ], ], ..., ], |
Grid rows
Grid rows are defined by parameter ROWS.
String parameters
Parameter | Type | Description |
---|---|---|
id | string / int | String identifier. |
columns | array | Array with data for column cells, in the format 'COLUMN_ID' => 'Cell data' , or 'COLUMN_ID' => [...] if column type is LABELS or TAGS from \Bitrix\Main\Grid\Column\Type.
|
data | array | Data for inline editing. For example, we can pass data for a cell to be displayed as is - inside the data cell we can pass data that are needed for editing.
'columns' => [ 'HREF' => '<a href="/my/url">My url</a>', ..., ], 'data' => [ 'HREF' => '/my/url', ..., ], Also, data can be used as an alternative for columns, for the backward compatibility with [link=11528238]previous legacy grid version[/link]. In case, 'columns' is not defined, grid will attempt to print data from 'data'. |
editableColumns | array | Defines cell as editable at the row level. For example, for an editable column you can specifically restrict cell editing by defining cell ID as false.
'editableColumns' => [ 'MY_COLUMN_ID' => false, ], |
actions | array | Defines actions available for the cell.
'actions' => [ [ 'delimiter' => boolean, 'className' => string, 'title' => string, 'text' => string, 'onclick' => string, 'href' => string, 'default' => boolean, 'items' => array, ], ..., ], |
custom | string | Arbitrary string content. Printed in a single cell. |
counters | array | Counters. Allows printing counters for any row's cell.
'counters' => [ 'COLUMN_ID' => [ 'type' => \Bitrix\Main\Grid\Counter\Type::LEFT, 'value' => 2, 'color' => 'counter-color-css-class', 'size' => 'counter-size-css-class', 'class' => 'counter-custom-css-class', ], ..., ], |
cellActions | array | Allows printing additional control actions for a cell.
'cellActions' => [ 'col1' => [ [ 'class' => [ \Bitrix\Main\Grid\CellActions::PIN, \Bitrix\Main\Grid\CellActionState::ACTIVE, ], 'events' => [ 'click' => 'onCellActionButtonClick', ], 'attributes' => [ 'data-test' => 'test', ], ], [ 'class' => [ \Bitrix\Main\Grid\CellActions::MUTE, \Bitrix\Main\Grid\CellActionState::ACTIVE, ], 'events' => [ 'click' => 'onCellActionButtonClick', ], 'attributes' => [ 'data-test' => 'test', ], ], ], ], |
© «Bitrix24», 2001-2024