ArtiGrid
Customs Buttons
This example demonstrates how to create fully customizable action buttons in ArtiGrid. Each button can be styled, configured with icons, and assigned specific behaviors for every row in the table.
Custom buttons support both JavaScript actions and external links. When a URL is provided,
the button is automatically rendered as an anchor element (<a>), allowing seamless navigation
to external or internal pages.
Dynamic placeholders such as {name} or {id} can be used within URLs and attributes.
These placeholders are replaced at runtime with the corresponding row values, enabling fully dynamic behavior.
You can also attach additional HTML attributes like data-*, onclick, or boolean attributes
such as disabled through the attributes parameter, giving you complete control over
the generated element.
Conditions allow you to control the visibility of each button based on row data.
They are defined using the format [field, operator, value]. In this example,
the button will only be displayed for rows where id != 1, providing precise and dynamic UI behavior.
<?php
$grid = new ArtiGrid();
$grid->table('products')
->template('bootstrap5')
->addCustomBtn(
'btn btn-sm btn-light',
'',
'<i class="fa fa-globe"></i>',
'Go',
['id', '!=', 31],
'https://google.cl/search?q={name}',
'_blank',
[
'data-name' => '{name}',
'onclick' => 'console.log("{id}")'
]
)
->modal();
echo $grid->render();
?>