Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Jacek Lukasiewicz  >  Bindable Simple Data Grid  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example use
Class: Bindable Simple Data Grid
Display and edit data on a table grid
Author: By
Last change:
Date: 2 years ago
Size: 1,200 bytes
 

Contents

Class file image Download
<?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>