<?php
include 'data/Person.php';
include 'data/DataSource.php';
include 'grid/SimpleGrid.php';
?>
<!DOCTYPE unspecified PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>SimpleGrid Examlpes</title>
<link type="text/css" rel="stylesheet" media="screen" href="style.css" />
</head>
<body>
<div id="wrapper">
<?php
$data = new DataSource();
$employersGrid = new SimpleGrid("EmployersGrid");
$customersGrid = new SimpleGrid("CustomersGrid");
$employersGrid->setHeaders(array('ID', 'Employer', 'Age' ));
$customersGrid->setHeaders(array('ID', 'Customer', 'Age', 'Notes'));
$employersGrid->readOnly();
$customersGrid->hide('id');
if(!empty($_POST)) {
$data->saveCustomers($customersGrid->getData());
} else {
$employersGrid->bind($data->getEmployers());
$customersGrid->bind($data->getCustomers());
}
?>
<form method="post">
<div>
<h2>Read-only grid</h2>
<?php echo $employersGrid->render(); ?>
</div>
<div>
<h2>Editable grid</h2>
<?php echo $customersGrid->render(); ?>
<input type="submit" value="Save..."/>
</div>
</form>
</div>
</body>
</html>
|