's id tag - WARNING : do not use '-' in table ids as it's used for generating javascript code
-// headers: an associative array "label"=>"type"
-// column_sort: the column to sort on at load-time
+// headers: an associative array; the values can take several forms
+// simple/legacy form is "label"=>"type"
+// more advanced form is "label"=>options, it self a dict with the following known keys
+// (*) 'type': the type for sorting; this is passed to the javascript layer for custom sorting
+// default is to use 'text', custom sort functions can be specified with e.g. 'type'=>'sortAlphaNumericBottom'
+// a special case is for type to be 'date-format' like e.g. 'type'=>'date-dmy'
+// setting type to 'none' gives an non-sortable column
+// (*) 'title': if set, this is used in the "Sort on ``''" bubble
+// sort_column: the column to sort on at load-time - set to negative number for no onload- sorting
// options : an associative array to override options
+// - bullets1 : set to true if you want decorative bullets in column 1 (need white background)
+// - stripes : use diferent colors for odd and even rows
+// - caption : a caption for the table -- never used I'm afraid
// - search_area : boolean (default true)
// - pagesize_area : boolean (default true)
// - notes_area : boolean (default true)
// - search_width : size in chars of the search text dialog
-// - notes : an array of additional notes
// - pagesize: the initial pagination size
// - pagesize_def: the page size when one clicks the pagesize reset button
// - max_pages: the max number of pages to display in the paginator
+// - notes : an array of additional notes
+// - debug: enables debug callbacks (prints out on console.log)
class PlekitTable {
// mandatory
var $table_id;
var $headers;
- var $column_sort;
+ var $sort_column;
// options
- var $caption;
+ var $bullets1; // boolean - default false - display decorative bullets in column 1
+ var $stripes; // boolean - default true - use different colors for odd and even rows
+ var $caption; // string - never used so far
var $search_area; // boolean (default true)
var $pagesize_area; // boolean (default true)
var $notes_area; // boolean (default true)
var $search_width; // size in chars of the search text dialog
- var $pagesize; // the initial pagination size
+ var $pagesize; // the initial pagination size
var $pagesize_def; // the page size when one clicks the pagesize reset button
var $max_pages; // the max number of pages to display in the paginator
var $notes; // an array of additional notes
+ var $debug; // set to true for enabling various log messages on console.log
+
+ // internal
var $has_tfoot;
- function PlekitTable ($table_id,$headers,$column_sort,$options=NULL) {
+ function PlekitTable ($table_id,$headers,$sort_column,$options=NULL) {
$this->table_id = $table_id;
$this->headers = $headers;
- $this->column_sort = $column_sort;
-
- $this->has_tfoot=false;
+ $this->sort_column = $sort_column;
+ $this->bullets1 = true;
+ $this->stripes=true;
+ $this->caption='';
$this->search_area = true;
$this->pagesize_area = true;
$this->notes_area = true;
$this->search_width = 40;
$this->pagesize = 25;
- $this->pagesize_def = 999;
+ $this->pagesize_def = 9999;
$this->max_pages = 10;
$this->notes = array();
+ $this->debug = false;
$this->set_options ($options);
+
+ // internal
+ $this->has_tfoot=false;
}
function set_options ($options) {
if ( ! $options)
return;
+ if (array_key_exists('bullets1',$options)) $this->bullets1=$options['bullets1'];
+ if (array_key_exists('stripes',$options)) $this->stripes=$options['stripes'];
if (array_key_exists('caption',$options)) $this->caption=$options['caption'];
if (array_key_exists('search_area',$options)) $this->search_area=$options['search_area'];
if (array_key_exists('pagesize_area',$options)) $this->pagesize_area=$options['pagesize_area'];
@@ -73,8 +97,8 @@ class PlekitTable {
if (array_key_exists('pagesize',$options)) $this->pagesize=$options['pagesize'];
if (array_key_exists('pagesize_def',$options)) $this->pagesize_def=$options['pagesize_def'];
if (array_key_exists('max_pages',$options)) $this->max_pages=$options['max_pages'];
-
if (array_key_exists('notes',$options)) $this->notes=array_merge($this->notes,$options['notes']);
+ if (array_key_exists('debug',$options)) $this->debug=$options['debug'];
}
public function columns () {
@@ -87,45 +111,59 @@ class PlekitTable {
$classname="paginationcallback-".$paginator;
$classname.=" max-pages-" . $this->max_pages;
$classname.=" paginate-" . $this->pagesize;
- // instantiate paginator callback
- print <<< EOF
-
-
-
column_sort rowstyle-alt colstyle-alt no-arrow $classname">
-
-EOF;
+ if ($this->bullets1) { $classname .= " bullets1"; }
+ if ($this->stripes) { $classname .= " rowstyle-alt"; }
+ if ($this->sort_column >= 0) { $classname .= " sortable-onload-$this->sort_column"; }
- if ($this->pagesize_area)
- print $this->pagesize_area_html ();
- if ($this->search_area)
- print $this->search_area_html ();
-
- if ($this->caption)
- print "