Exemplo n.º 1
0
include_once 'PhpExt/Data/SimpleStore.php';
include_once 'PhpExt/Form/FieldSet.php';
include_once 'PhpExt/Form/TextField.php';
include_once 'PhpExt/Form/DateField.php';
include_once 'PhpExt/Form/ComboBox.php';
include_once 'PhpExt/Config/ConfigObject.php';
include_once 'PhpExt/Button.php';
include_once 'PhpExt/Handler.php';
include_once 'PhpExt/QuickTips.php';
include_once 'PhpExtUx/Form/XmlErrorReader.php';
$fs = new PhpExt_Form_FormPanel();
$fs->setFrame(true)->setTitle("XML Form")->setLabelAlign(PhpExt_Form_FormPanel::LABEL_ALIGN_RIGHT)->setLabelWidth(85)->setWidth(340)->setWaitMsgTarget(true);
// configure how to read the XML Data
$reader = new PhpExt_Data_XmlReader();
$reader->setRecord("contact")->setSuccess("@success");
$reader->addField(new PhpExt_Data_FieldConfigObject("first", "name/first"));
// custom mapping
$reader->addField(new PhpExt_Data_FieldConfigObject("last", "name/last"));
$reader->addField(new PhpExt_Data_FieldConfigObject("company", "company"));
$reader->addField(new PhpExt_Data_FieldConfigObject("email", "email"));
$reader->addField(new PhpExt_Data_FieldConfigObject("state", "state"));
$reader->addField(new PhpExt_Data_FieldConfigObject("dob", "dob", "date", "m/d/Y"));
// custom data types
$fs->setReader($reader);
$fs->setErrorReader(new PhpExtUx_Form_XmlErrorReader());
$fset = new PhpExt_Form_FieldSet();
$fset->setTitle("Contact Information")->setAutoHeight(true)->setDefaultType("textfield")->setDefaults(new PhpExt_Config_ConfigObject(array("width" => 190)))->addItem(PhpExt_Form_TextField::createTextField("first", "First Name"))->addItem(PhpExt_Form_TextField::createTextField("last", "Last Name"))->addItem(PhpExt_Form_TextField::createTextField("company", "Company"))->addItem(PhpExt_Form_TextField::createTextField("email", "Email", null, PhpExt_Form_FormPanel::VTYPE_EMAIL));
$combo = PhpExt_Form_ComboBox::createComboBox("state", "State")->setValueField("abbr")->setDisplayField("state")->setTypeAhead(true)->setMode(PhpExt_Form_ComboBox::MODE_LOCAL)->setTriggerAction(PhpExt_Form_ComboBox::TRIGGER_ACTION_ALL)->setEmptyText("Select a state...")->setSelectOnFocus(true);
$store = new PhpExt_Data_SimpleStore();
$store->addField("abbr");
$store->addField("state");
Exemplo n.º 2
0
<?php

set_include_path(get_include_path() . PATH_SEPARATOR . realpath('../../library'));
include_once 'PhpExt/Javascript.php';
PhpExt_Javascript::sendContentType();
include_once 'PhpExt/Ext.php';
include_once 'PhpExt/Data/Store.php';
include_once 'PhpExt/Data/XmlReader.php';
include_once 'PhpExt/Data/FieldConfigObject.php';
include_once 'PhpExt/Grid/ColumnModel.php';
include_once 'PhpExt/Grid/ColumnConfigObject.php';
include_once 'PhpExt/Grid/GridPanel.php';
// Xml Reader
$reader = new PhpExt_Data_XmlReader();
$reader->setRecord("Item")->setTotalRecords("@total")->setId("ASIN");
$reader->addField(new PhpExt_Data_FieldConfigObject("Author", "ItemAttributes > Author"));
$reader->addField(new PhpExt_Data_FieldConfigObject("Title"));
$reader->addField(new PhpExt_Data_FieldConfigObject("Manufacturer"));
$reader->addField(new PhpExt_Data_FieldConfigObject("ProductGroup"));
// Store
$store = new PhpExt_Data_Store();
$store->setUrl("examples/grid/sheldon.xml")->setReader($reader);
// ColumnModel
$colModel = new PhpExt_Grid_ColumnModel();
$colModel->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Author", "Author", null, 120, null, null, true))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Title", "Title", null, 180, null, null, null, true))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Manufacturer", "Manufacturer", null, 115, null, null, true))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Product Group", "ProductGroup", null, 100, null, null, true));
// Grid
$grid = new PhpExt_Grid_GridPanel();
$grid->setStore($store)->setColumnModel($colModel)->setHeight(200)->setWidth(540)->setTitle("Xml Grid");
// Ext.OnReady -----------------------
echo PhpExt_Ext::onReady($store->getJavascript(false, "store"), $grid->getJavascript(false, "grid"), $grid->render("example-grid"), $store->load());