Created
April 20, 2011 16:59
-
-
Save AngeloR/931922 to your computer and use it in GitHub Desktop.
Example of OPCDataGrid usage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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