PHP code example of mmollay / gridkit

1. Go to this page and download the library: Download mmollay/gridkit library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mmollay / gridkit example snippets



ridKit\Table;

(new Table('products'))
    ->query($db, "SELECT * FROM products ORDER BY name")
    ->search(['name', 'sku'])
    ->column('sku',       'SKU',     ['width' => '120px', 'muted' => true])
    ->column('name',      'Product', ['sortable' => true])
    ->column('price',     'Price',   ['format' => 'currency', 'sortable' => true])
    ->column('is_active', 'Status',  ['format' => 'label'])
    ->button('edit',   ['icon' => 'edit',   'modal' => 'edit_product'])
    ->button('delete', ['icon' => 'delete', 'confirm' => true])
    ->modal('edit_product', 'Edit', 'forms/product.php', ['size' => 'medium'])
    ->newButton('New product', ['modal' => 'edit_product'])
    ->paginate(25)
    ->render();

<link rel="stylesheet" href="<?= Layout::asset('vendor/mmollay/gridkit/css/gridkit.css') 

(new Form('product'))
    ->field('sku',   'SKU',     'text',     ['idth' => 12])
    ->field('notes', 'Notes',   'textarea', ['width' => 16])
    ->field('unit',  'Unit',    'select',   ['options' => $units, 'width' => 6])
    ->field('pack', 'Pack size', 'text',   ['width' => 6, 'showIf' => ['field' => 'unit', 'equals' => 'pcs']])  // only while the unit is pcs
    ->values($product)                  // fill every field from a record, by name
    ->errors($errors)                   // show a failed save's messages, by name
    ->render();
bash
git clone https://github.com/mmollay/gridkit.git
cd gridkit && php tests/run.php