Skip to content

Instantly share code, notes, and snippets.

@AngeloR
Created April 20, 2011 16:59
Show Gist options
  • Save AngeloR/931922 to your computer and use it in GitHub Desktop.
Save AngeloR/931922 to your computer and use it in GitHub Desktop.
Example of OPCDataGrid usage
<?php
$res = db('select product_id,name,short_description from products order by name asc');
$dg = new OPCDataGrid($res);
$dg->fields(array(
'name' => 'Product Name',
'short_description' => 'Description'
));
$dg->addField('Added', 'added', 'this field has been added',array('after'=>'short_description'));
$dg->modify('name', function($value,$row) {
return '<a href="'.url_for('products',$row['product_id']).'">'.$value.'</a>';
});
$dg->modify('short_description',function($value,$row){
$str = trim(substr($value,0,60));
return $str.'...';
});
$dg->render();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment