SwatTableViewInputRow Demo
SwatML for this demo:
<?xml version="1.0" standalone="no"?>
<!DOCTYPE swatml SYSTEM "http://swat.silverorange.com/swatml1.dtd">
<swatml>
<widget class="SwatForm" id="my_form">
<widget class="SwatTableView" id="table_view">
<object class="SwatTableViewCheckboxColumn" id="checkbox">
<object class="SwatCheckboxCellRenderer" id="items">
<property name="value" type="data">title</property>
</object>
<object class="SwatRemoveInputCell" />
</object>
<object class="SwatTableViewColumn">
<property name="title">Fruit</property>
<object class="SwatTextCellRenderer">
<property name="text" type="data">title</property>
</object>
<object class="SwatInputCell">
<widget class="SwatEntry">
<property name="size" type="integer">10</property>
</widget>
</object>
</object>
<object class="SwatTableViewColumn">
<property name="title">Makes Jam</property>
<object class="SwatBooleanCellRenderer">
<property name="value" type="data">makes_jam</property>
</object>
<object class="SwatInputCell">
<widget class="SwatCheckbox" />
</object>
</object>
<object class="SwatTableViewColumn">
<property name="title">Makes Pie</property>
<object class="SwatBooleanCellRenderer">
<property name="value" type="data">makes_pie</property>
</object>
<object class="SwatInputCell">
<widget class="SwatCheckbox" />
</object>
</object>
<object class="SwatTableViewInputRow" id="input_row">
<property name="number" type="integer">2</property>
</object>
</widget>
<widget class="SwatMessageDisplay" id="note" />
<widget class="SwatActions" id="index_actions">
<property name="show_blank" type="boolean">false</property>
<widget class="SwatActionItem" id="add">
<property name="title">add new items</property>
</widget>
<widget class="SwatActionItemDivider" />
<widget class="SwatActionItem" id="makes_jam">
<property name="title">set jammable…</property>
<widget class="SwatFormField">
<property name="title">to</property>
<widget class="SwatYesNoFlydown">
</widget>
</widget>
</widget>
</widget>
</widget>
</swatml>
PHP for this demo:
<?php
/* vim: set noexpandtab tabstop=4 shiftwidth=4 foldmethod=marker: */
require_once 'Demo.php';
/**
* A demo using a table view
*
* @package SwatDemo
* @copyright 2006-2007 silverorange
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
*/
class TableViewInputRowDemo extends Demo
{
// {{{ public function buildDemoUI();
public function buildDemoUI(SwatUI $ui)
{
$message = new SwatMessage(
'These actions are for demonstration purposes only.');
$message->secondary_content =
'The actions do not do anything as this page is not connected '.
'to a database.';
$ui->getWidget('note')->add($message, SwatMessageDisplay::DISMISS_OFF);
$data = array(
array('Apple', false, true),
array('Orange', false, false),
array('Strawberry', true, false),
);
$table_view = $ui->getWidget('table_view');
$table_store = new SwatTableStore();
foreach ($data as $datum) {
$fruit = new FruitObject();
$fruit->title = $datum[0];
$fruit->makes_jam = $datum[1];
$fruit->makes_pie = $datum[2];
$table_store->addRow($fruit);
}
$table_view->model = $table_store;
}
// }}}
}
/**
* A demo using a table view
*
* @package SwatDemo
* @copyright 2006 silverorange
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
*/
class FruitObject
{
// {{{ public properties
public $title = '';
public $makes_jam = false;
public $makes_pie = false;
// }}}
}
?>