After several requests from valuable customer, i’ve added option to display php grid from php array data as input (no database connection required).

It’s usage is very simple. Suppose you have an array, then all you have to do is to pass it in table parameter. See code sample below. Do consider the format of array should be consistent as it is in example (data and colums may change).

$name = array('Pepsi 1.5 Litre', 'Sprite 1.5 Litre', 'Cocacola 1.5 Litre', 'Dew 1.5 Litre', 'Nestle 1.5 Litre');
for ($i = 0; $i < 200; $i++)
{
    $data[$i]['id']    = $i+1;
    $data[$i]['code']    = $name[rand(0, 4)][0].($i+5);
    $data[$i]['name']    = $name[rand(0, 4)];
    $data[$i]['cost']    = rand(0, 100)." USD";
    $data[$i]['quantity'] = rand(0, 100);
    $data[$i]['discontinued'] = rand(0, 1);
    $data[$i]['email'] = 'buyer_'. rand(0, 100) .'@google.com';
    $data[$i]['notes'] = '';
}

// pass data in table param for local array grid display
$g->table = $data;

This will show the grid in read only mode, and options like search, sorting and paging will be available. You can also use custom formatter to change display of data in grid, for e.g. making hyperlink or show as tag etc. Working example included in package.

How useful was this post?

Click on a star to rate it!

Average rating / 5. Vote count:

As you found this post useful...

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!

Leave a Reply