Source for file grids.inc.php
Documentation is available at grids.inc.php
* This file is part of the VCL for PHP project
* Copyright (c) 2004-2007 qadram software <support@qadram.com>
* Checkout AUTHORS file for more information on the developers
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* This class represents a grid column
function getTitle() { return $this->_title; }
function setTitle($value) { $this->_title= $value; }
* This class represents a grid row
function getHeight() { return $this->_height; }
function setHeight($value) { $this->_height= $value; }
protected $_highlightrows=1;
protected $_showrownumbers=1;
function __construct($aowner=null)
//Calls inherited constructor
parent::__construct($aowner);
$this->columns=new Collection();
$this->rows=new Collection();
function dumpHeaderCode()
echo "<link type=\"text/css\" rel=\"stylesheet\" href=\"".VCL_HTTP_PATH."/os3grid/os3grid.css\" />\n";
echo "<script src=\"".VCL_HTTP_PATH."/os3grid/os3grid.js\" type=\"text/javascript\"></script>\n";
protected $_jsonrowselect=null;
function getjsOnRowSelect () { return $this->_jsonrowselect; }
function setjsOnRowSelect($value) { $this->_jsonrowselect=$value; }
function defaultjsOnRowSelect () { return ""; }
protected $_jsoncoldisplay=null;
function getjsOnColDisplay () { return $this->_jsoncoldisplay; }
function setjsOnColDisplay($value) { $this->_jsoncoldisplay=$value; }
function defaultjsOnColDisplay () { return ""; }
function dumpRowSelect($event)
echo "function $event(grid, row, selected)\n";
$this->owner->$event($this, array());
function dumpColDisplay($event)
echo "function $event(grid, col_num, value)\n";
$this->owner->$event($this, array());
$this->dumpRowSelect($this->_jsonrowselect);
$this->dumpColDisplay($this->_jsoncoldisplay);
$style.="height:".$this->Height."px;width:".$this->Width."px;";
if ($style!="") $style="style=\"$style\"";
echo "<div id=\"".$this->Name."_grid\" $style></div>\n";
echo "<script type=\"text/javascript\">\n";
// echo "function updatecontrol() {\n";
// echo "alert('updatecontrol');\n";
echo "var g = new OS3Grid ();\n";
if ($this->columns->count()>=1)
for ($i=0;$i<=$this->columns->count()-1;$i++)
$column=$this->columns->items[$i];
if ($headers!='') $headers.=',';
//echo "g.set_col_editable ( $c, \"txt\" );\n";
echo "g.set_headers ( $headers );\n";
echo "g.set_scrollbars ( true );\n";
echo "g.start_counter = 1;\n";
if ($this->_jsonrowselect!=null)
$event=$this->_jsonrowselect;
echo "g.onrowselect = $event; \n";
if ($this->_jsoncoldisplay!=null)
$event=$this->_jsoncoldisplay;
echo "g.oncoldisplay = $event; \n";
// echo "g.set_row_select ( true );\n";
echo "g.set_border ( 1, \"solid\", \"#cccccc\" );\n";
echo "g.set_sortable(".$this->_sortable.");\n";
// echo "g.set_highlight(".$this->_highlightrows.");\n";
// echo "g.show_row_num(".$this->showrownumbers.");\n";
if ($this->rows->count()>=1)
for ($k=0;$k<=$this->rows->count()-1;$k++)
$row=$this->rows->items[$k];
for ($i=0;$i<=$this->columns->count()-1;$i++)
$column=$this->columns->items[$i];
if ($rowvalues!="") $rowvalues.=",";
$text=str_replace("\n",'\n',$text);
$text=str_replace("\r",'',$text);
$text=str_replace("'","\\'",$text);
echo "g.add_row ( $rowvalues );\n";
// echo "alert('no values');\n";
echo "g.add_row ( 'value' );\n";
echo "g.render ( '".$this->Name."_grid' );\n";
// echo "updatecontrol();\n";
function getSortable() { return $this->_sortable; }
function setSortable($value) { $this->_sortable=$value; }
function getHighLightRows() { return $this->_highlightrows; }
function setHighLightRows($value) { $this->_highlightrows=$value; }
//ShowRowNumbers property
function getShowRowNumbers() { return $this->_showrownumbers; }
function setShowRowNumbers($value) { $this->_showrownumbers=$value; }
class StringGrid extends ListView
|