Grid View - Max MVC

Below is sample documentation that explains how to configure each column in your grid. You can include this in your project’s documentation (for example, as a README or developer guide).


Grid Column Data Structure

Each column in the grid is defined as an associative array. The following keys are available:

Required Keys

Optional Keys

Example of a Complete Column Configuration

Below is a sample array of columns that demonstrates how to configure different aspects:

$columns = [
  [
    'name'       => 'Order ID',
    'data'       => 'order_id',
    'width'      => '80px',
    'align'      => 'left',
    'sortable'   => true,
    'filter'     => 'text',
  ],
  [
    'name'       => 'Customer',
    'data'       => 'customer_name',
    'width'      => '150px',
    'align'      => 'left',
    'sortable'   => true,
    'filter'     => 'select',
  ],
  [
    'name'       => 'Price',
    'data'       => 'price',
    'width'      => '80px',
    'align'      => 'right',
    'formatter'  => 'number_format($item["price"], 2, ".", ",")',
    'aggregate'  => 'sum',
    'sortable'   => true,
    'filter'     => 'none',
  ],
  [
    'name'       => 'Quantity',
    'data'       => 'quantity',
    'width'      => '60px',
    'align'      => 'right',
    'aggregate'  => 'sum',
    'sortable'   => true,
    'filter'     => 'none',
  ],
  [
    'name'       => 'Total',
    'data'       => '{price} * {quantity}', // Calculated column using tokens
    'width'      => '100px',
    'align'      => 'right',
    'formatter'  => 'number_format($value, 2, ".", ",")', // $value refers to the computed total
    'aggregate'  => 'sum',
    'sortable'   => false,
    'filter'     => 'none',
  ],
  [
    'name'       => 'Secret Code',
    'data'       => 'secret_code',
    'hide'       => true, // Hidden from the view but used for calculations or references
    'sortable'   => false,
    'filter'     => 'none',
  ],
];

Notes


This documentation provides an overview of how to set up and customize the grid’s column definitions. Adjust the examples to match your application’s needs, and feel free to extend the configuration with additional keys or logic as required.


Revision #2
Created 16 February 2025 18:16:10 by Max
Updated 16 February 2025 18:21:40 by Max