PlatinumGrid
develop faster.

PlatinumGrid has an extremely simple and flexible API. This allows developers to begin using PlatinumGrid very quickly, and allows them to access even advanced features with ease. This page demonstrates this easy-to-use API.

PlatinumGrid ships with over 30 examples covering virtually all features of the grid, that provide a simple and effective way of showing how to use the API. We've taken a few of these examples to convey some idea of the simplicity of using PlatinumGrid in any PHP application.

Note. For applications written using RadPHP, PlatinumGrid is a drag-and-drop component with complete integration into the RPCL. This page is intended for the developers who do not use RadPHP.

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';

$detailDataSource = new MySQLDatasource$dbConnection );
$detailDataSource->DataSet->MasterSource $masterDataSource;
$detailDataSource->DataSet->MasterDetailKeys = array( 'CustomerID' => 'CustomerID' );
$detailDataSource->DataSet->TableName 'orderslt';

// 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 Master-Detail Demo</title>
<?php
$masterGrid
->dumpHeaderCode();
?>
</head>
<body>
  <h1>Basic Master-Detail Demo</h1>
  <form action="" method="post">
    <div id="<?php echo( $masterGrid->Name ); ?>_outer">
<?php $masterGrid->dumpContents(); ?>
    </div>
  </form>
</body>
</html>