PlatinumGrid
develop faster.

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.

Ajax:
PlatinumGrid fully supports Ajax, and does not tie you into one particular Ajax library, but offers maximum flexibility. In this example, it doesn't use an Ajax library, but a few small JavaScript methods handle the Ajax calls.
<?php
require_once( '../grid.inc.php' );

$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->ajaxJSMethod 'ajaxCall()';
$grid->Datasource $dataSource;
$grid->Height '';
$grid->SiteTheme->Theme 'default';

$col1 = new JTPlatinumGridTextColumn$grid );
$col1->Caption 'ID';
$col1->DataField 'ID';
$col1->Name 'IDCol';

$col2 = new JTPlatinumGridTextColumn$grid );
$col2->Caption 'First Name';
$col2->DataField 'FirstName';
$col2->Name 'FirstNameCol';

$col3 = new JTPlatinumGridTextColumn$grid );
$col3->Caption 'Last Name';
$col3->DataField 'LastName';
$col3->Name 'LastNameCol';

$col4 = new JTPlatinumGridTextColumn$grid );
$col4->Caption 'Department';
$col4->DataField 'Department';
$col4->Name 'DepartmentCol';

$grid->Columns = array( $col1$col2$col3$col4 );

$grid->init();

// If it's an Ajax call, handle it.
if( $_POST'ajax' ] == '1' )
{
    
$gridCode $grid->dumpForAjax();

    
$gridResponse = new stdClass();
    
$gridResponse->id $grid->Name '_outerdiv';
    
$gridResponse->html $gridCode];
    
$gridResponse->jsCode $gridCode];

    die( 
json_encode( array( $gridResponse ) ) );
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
  <title>Basic Demo</title>
  <script language="JavaScript" type="text/javascript">
// Some boiler-plate Ajax methods. These could easily be handled by an Ajax library
// such as Xajax.
function processAjaxResponse( responseText, callBackParameters ) {
    var elements = eval( responseText );
    for( var i = 0; i < elements.length; ++i ) {
        document.getElementById( elements[ i ].id ).innerHTML = elements[ i ].html;
        eval( elements[ i ].jsCode );
    }
}

function getFormValuesAsPost() {
    var form = document.forms[ 0 ];
    var result = [];
    for( var i = 0; i < form.elements.length; ++i ) {
        if( form.elements[ i ].type == "checkbox" && !form.elements[ i ].checked )
            continue;
        result.push( form.elements[ i ].name + "=" + encodeURIComponent( form.elements[ i ].value ) );
    }
    return result.join( "&" );
}

function sendAjaxRequest( url, data, callBack, callBackParameters ) {
    var request = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject( "Microsoft.XMLHTTP" );
    var ifModifiedSince = new Date( 0 );

    request.open( "POST", url, true );
    request.setRequestHeader( "If-Modified-Since", ifModifiedSince );
    request.setRequestHeader( "Content-type", "application/x-www-form-urlencoded" );
    request.setRequestHeader( "Content-length", data.length );
    request.onreadystatechange = function() {
        if( request.readyState == 4 && request.status == 200 ) {
            if( request.responseText )
                callBack( request.responseText, callBackParameters );
        }
    }

    request.send( data );
}
function ajaxCall( action, parameters ) {
    var query = "ajax=1&" + getFormValuesAsPost();
    if( action )
        query += "&action=" + action;
    if( typeof( parameters ) != "undefined" )
        query += "&params=" + parameters;
    sendAjaxRequest( "<?php echo( $_SERVER'PHP_SELF' ] ); ?>", query, processAjaxResponse, null );
}
  </script>
<?php
$grid
->dumpHeaderCode();
?>
</head>
<body>
  <h1>Basic Demo</h1>
  <form action="" method="post">
    <div id="<?php echo( $grid->Name ); ?>_outer">
<?php $grid->dumpContents(); ?>
    </div>
  </form>
</body>
</html>