ArtiGrid
Columns Reorder
Column Drag & Rename: This demo allows you to
rearrange columns by dragging them to a different position and rename
column labels to customize the table display. In this example, the
productName column is displayed as Number.
<?php
$gid = 'products';
$uid = $_SESSION['user_id'] ?? 'anon';
$q = new Queryfy(DB::connect());
$row = $q->table('artigrid_col_order')
->where('user_id', $uid)
->where('grid_id', $gid)
->limit(1)
->get();
$colOrder = [];
if (!empty($row[0]['col_order'])) {
$decoded = json_decode($row[0]['col_order'], true);
if (is_array($decoded)) {
$colOrder = $decoded;
}
}
$grid = new ArtiGrid();
$grid->table('products')
->template('bootstrap5')
->columnDrag(true)
->colRename('productName', 'Number');
if (!empty($colOrder)) {
$grid->crudCol($colOrder);
}
$grid->modal();
echo $grid->render();
?>