Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
include_once AKPATH_HTML.'/grid.php' ;
// Create a new Grid
$grid = new AKGrid( array('class' => 'adminlist', 'id' => 'table_id') );
// Set Columns
$grid->setColumns( array('week_start', 'price', 'discount', 'delete') ) ;
// Add First TR Row as thead
$grid->addRow( array() , 1); // 1 means th, 0 means tfoot, none means tbody
$grid->setRowCell('week_start', '週數', array('class' => 'center')) ;
$grid->setRowCell('price', '價格', array('class' => 'center')) ;
$grid->setRowCell('discount', '優惠', array('class' => 'center')) ;
$grid->setRowCell('delete', '刪除', array('class' => 'center')) ;
// Batch Add td Rows
foreach( $values as $k => $value ):
// Add a Row
$grid->addRow( array( 'class' => 'row'.($k%2) ) );
// Add tds
$grid->setRowCell('week_start', $value->a_week_start, array('class' => 'center')) ;
$grid->setRowCell('price', $value->a_price, array('class' => 'center')) ;
$grid->setRowCell('discount', $value->a_discount, array('class' => 'center')) ;
$grid->setRowCell('delete', '<input type="button" value="刪除" onclick="Tour.removePricetype(\''.$this->id.'\', \''.$value->a_id.'\')" />', array('class' => 'center')) ;
endforeach;
// toString
$html = (string) $grid;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.