For applications written using Delphi For PHP, PlatinumGrid is a drag-and-drop component with complete
integration into the VCL For PHP. This page is intended for the developers who do not use
Delphi For PHP, to demonstrate the easy API that PlatinumGrid provides.
Persistence:
To persist the grid state during the session is easy. All one has to do is call the grid's serialize and unserialize
methods to write/read the grid's state into the session.
<?php
require_once( '../grid.inc.php' );
// Start the session.
session_start();
$dbConnection = mysql_connect( 'localhost', 'root', '' );
mysql_select_db( 'gridsamples', $dbConnection );
$dataSource = new MySQLDatasource( $dbConnection );
$dataSource->DataSet->TableName = 'employeestiny';
$dataSource->DataSet->Open();
// Construct the grid.
$grid = new JTPlatinumGrid();
$grid->Datasource = $dataSource;
$grid->Height = '';
$grid->SiteTheme->Theme = 'default';
// Initialize the session.
if( !isset( $_SESSION[ 'sid' ] ) || $_GET[ 'restore_session' ] == '1' )
{
// If the SESSION hasn't been created, set some properties on the grid.
$grid->CanRangeSelect = false;
$grid->Header->ShowFilterBar = false;
$grid->Height = 540;
$grid->Width = 955;
// And create the columns.
$textCol1 = new JTPlatinumGridTextColumn( $grid );
$textCol1->Caption = 'First Name';
$textCol1->DataField = 'FirstName';
$textCol1->Name = 'FirstNameCol';
$textCol2 = new JTPlatinumGridTextColumn( $grid );
$textCol2->Caption = 'Last Name';
$textCol2->DataField = 'LastName';
$textCol2->Name = 'LastNameCol';
$textCol3 = new JTPlatinumGridTextColumn( $grid );
$textCol3->Caption = 'Department';
$textCol3->DataField = 'Department';
$textCol3->Name = 'DepartmentCol';
$grid->Columns = array( $textCol1, $textCol2, $textCol3 );
}
else
{
// The session has been created, so tell the grid to read it.
$grid->unserialize();
}
$grid->init();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Basic Demo</title>
<?php
$grid->dumpHeaderCode();
?>
</head>
<body>
<h1>Basic Demo</h1>
<form action="" method="post">
<div id="<?php echo( $grid->Name ); ?>_outer">
<?php $grid->dumpContents(); ?>
</div>
<input type="submit" value="Click to refresh page" />
</form>
</body>
</html>
<?php
// Put the grid into the session.
$grid->serialize();
// Store our own identifier, so that we know whether the session is created.
$_SESSION[ 'sid' ] = 1;
Copyright © JomiTech 2009. All Rights Reserved. |
Privacy Policy