Simple PHP:DataGrid Demo with a Button

This demo shows the use of a button.


ID Title Category Author
1 Item 1 3 Dennis
2 Item 2 5 John
3 Item 3 2 Chris
4 Item 4 3 Jeremy
5 Item 5 6 Chris
6 Item 6 5 John
7 Item 7 3 Dennis
8 Item 8 7 Chris
9 Item 9 8 Dennis
10 Item 10 3 Jeremy
11 Item 11 9 Dennis
12 Item 12 3 John
13 Item 13 2 Chris
14 Item 14 1 Dennis
15 Item 15 5 John
16 Item 16 3 Jeremy

Source:

<?php
include ('phpdatagrid.php');

// Include Sample data
include ('sampledata.php');

// Bind data to datagrid
$_DATAGRID->bind ('demo'$data);

?>
<html>
    <head>
        <title>PHP:DataGrid - Demo 3</title>
    </head>

    <body>

    <h1>Simple PHP:DataGrid Demo with a Button</h1>

    <p>This demo shows the use of a button.</p>

    <hr />

    <?php 
    
// Show details or not?
    
if (DG_ACTION == 'viewdetails') {
        echo 
'<strong>ID: </strong>' $_DATAGRID->data[DG_ROW]['id'] . '<br />';
        echo 
'<strong>Title: </strong>' $_DATAGRID->data[DG_ROW]['title'] . '<br />';
        echo 
'<strong>Category: </strong>' $_DATAGRID->data[DG_ROW]['category'] . '<br />';
        echo 
'<strong>Author: </strong>' $_DATAGRID->data[DG_ROW]['author'] . '<br /><br />';
    }
    
?>

    <php:datagrid name="demo" width="100%" AutoGenerateColumns="false" cellpadding="5" cellspacing="0" border="true">
        <Style font-family="Verdana" background-color="#eeeeee" font-size="12px" />
        <HeaderStyle Background-Color="#000" bold="true" text-color="#fff" />
        <AlternateItemStyle background-color="#fff" />

        <Column datafield="id" HeaderText="ID" />
        <Column datafield="title" HeaderText="Title" />
        <Column datafield="category" HeaderText="Category" />
        <Column datafield="author" HeaderText="Author" />
        <Button name="details" text="Details" width="10%" ItemStyle-text-align="center" action="viewdetails" />
    </php:datagrid>

    <hr />

    <h2>Source:</h2>
    <div style="background-color: #EFEFEF;"><?php highlight_file(__FILE__); ?></div>
    
    </body>
</html>