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.
Master-Detail:
Showing master-detail views with PlatinumGrid is very simple, as the grid takes care of generating the correct result
set and embedding the detail grid.
<?php
require_once( '../grid.inc.php' );
$dbConnection = mysql_connect( 'localhost', 'root', '' );
mysql_select_db( 'gridsamples', $dbConnection );
$masterDataSource = new MySQLDatasource( $dbConnection );
$masterDataSource->DataSet->TableName = 'customerslt';
$masterDataSource->DataSet->Open();
$detailDataSource = new MySQLDatasource( $dbConnection );
$detailDataSource->DataSet->MasterSource = $masterDataSource;
$detailDataSource->DataSet->MasterDetailKeys = array( 'CustomerID' => 'CustomerID' );
$detailDataSource->DataSet->TableName = 'orderslt';
$detailDataSource->DataSet->Open();
// Construct the master grid.
$masterGrid = new JTPlatinumGrid();
$masterGrid->Datasource = $masterDataSource;
$masterGrid->DetailView->DetailField = 'CustomerID';
$masterGrid->DetailView->Enabled = true;
$masterGrid->Height = '';
$masterGrid->Name = 'masterGrid';
$masterGrid->KeyField = 'CustomerID';
$masterGrid->SiteTheme->Theme = 'default';
$masterCol1 = new JTPlatinumGridTextColumn( $masterGrid );
$masterCol1->Caption = 'CustomerID';
$masterCol1->DataField = 'CustomerID';
$masterCol1->Name = 'IDCol';
$masterCol2 = new JTPlatinumGridTextColumn( $masterGrid );
$masterCol2->Caption = 'First Name';
$masterCol2->DataField = 'FirstName';
$masterCol2->Name = 'FirstNameCol';
$masterCol3 = new JTPlatinumGridTextColumn( $masterGrid );
$masterCol3->Caption = 'Last Name';
$masterCol3->DataField = 'LastName';
$masterCol3->Name = 'LastNameCol';
$masterGrid->Columns = array( $masterCol1, $masterCol2, $masterCol3 );
// Construct the detail grid.
$detailGrid = new JTPlatinumGrid();
$detailGrid->Datasource = $detailDataSource;
$detailGrid->Height = '';
$detailGrid->Name = 'detailGrid';
$detailGrid->SiteTheme->Theme = 'default';
$detailCol1 = new JTPlatinumGridTextColumn( $detailGrid );
$detailCol1->Caption = 'SalesOrderID';
$detailCol1->DataField = 'SalesOrderID';
$detailCol1->Name = 'SalesOrderIDCol';
$detailCol2 = new JTPlatinumGridTextColumn( $detailGrid );
$detailCol2->Caption = 'SubTotal';
$detailCol2->DataField = 'SubTotal';
$detailCol2->Name = 'SubTotalCol';
$detailCol3 = new JTPlatinumGridTextColumn( $detailGrid );
$detailCol3->Caption = 'Total';
$detailCol3->DataField = 'Total';
$detailCol3->Name = 'TotalCol';
$detailGrid->Columns = array( $detailCol1, $detailCol2, $detailCol3 );
$masterGrid->DetailView->DetailGrid = $detailGrid;
$masterGrid->init();
$detailGrid->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
$masterGrid->dumpHeaderCode();
?>
</head>
<body>
<h1>Basic Demo</h1>
<form action="" method="post">
<div id="<?php echo( $masterGrid->Name ); ?>_outer">
<?php $masterGrid->dumpContents(); ?>
</div>
</form>
</body>
</html>
Copyright © JomiTech 2009. All Rights Reserved. |
Privacy Policy