Ejemplo n.º 1
0
$paging->getPlugins()->add($filter_plugin);
$txt_nombre = new PhpExt_Form_TextField();
$txt_descripcion = new PhpExt_Form_TextField();
$modulos = array();
if ($listado_modulos = OOB_module::listModules()) {
    foreach ($listado_modulos as $modulo) {
        $modulos[] = array($modulo->name(), $modulo->nicename());
    }
    //end each
}
//end if
$store_modulos = new PhpExt_Data_SimpleStore();
$store_modulos->addField("id");
$store_modulos->addField("detalle");
$store_modulos->setData(PhpExt_Javascript::variable(json_encode($modulos)));
$cbo_modulo = PhpExt_Form_ComboBox::createComboBox("cbo_modulo")->setStore($store_modulos)->setDisplayField("detalle")->setValueField("id")->setLazyRender(true)->setEditable(false)->setForceSelection(true)->setSingleSelect(true)->setMode(PhpExt_Form_ComboBox::MODE_LOCAL)->setTriggerAction(PhpExt_Form_ComboBox::TRIGGER_ACTION_ALL);
$format_contacto = "\n\t function( v, params, record , rowIndex, colIndex, store ){\t\t\t\n\t\treturn record.data['contacto'];\n\t }\n";
$format_modulo = "\n\t function( v, params, record , rowIndex, colIndex, store ){\t\t\t\n\t\treturn record.data['modulenicename'];\n\t }\n";
$col_model = new PhpExt_Grid_ColumnModel();
$col_model->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Id", "id", null, 30));
$col_model->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Nombre", "nombre", null, 280)->setEditor($txt_nombre));
$col_model->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Descripción", "descripcion", null, 280)->setEditor($txt_descripcion));
$col_model->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Modulo", "modulo", null, 80, PhpExt_Ext::HALIGN_RIGHT, new PhpExt_JavascriptStm($format_modulo))->setEditor($cbo_modulo));
$grid = new PhpExt_Grid_EditorGridPanel();
$grid->setStore($store)->setColumnModel($col_model)->setSelectionModel(new PhpExt_Grid_RowSelectionModel())->setLoadMask(true)->setenableColLock(false);
$grid->getPlugins()->add($filter_plugin);
$grid->getPlugins()->add(new PhpExtUx_App_FitToParent());
$grid->setBottomToolbar($paging);
$grid_render = "\n\nvar store = grid.getStore();\n\ngrid.on('validateedit', function(e){\n    if(e.field == 'modulo'){\n\t\tvar combo = grid.getColumnModel().getCellEditor(e.column, e.row).field;\t\t\t\t \t\t \n        e.record.data['modulenicename'] = combo.getRawValue();\n    }\t\n});\n\n\nvar nuevo = function(){\n\nvar cmodel = Ext.data.Record.create([\n\t\t\t\t   {name: 'id'},\n\t\t\t\t   {name: 'nombre', type: 'string'},\n\t\t\t\t   {name: 'sucursal', type: 'string'},\n\t\t\t\t   {name: 'contacto', type: 'string'},\n\t\t\t\t   {name: 'sucursal::nombre'},\n\t\t\t\t   {name: 'contacto::apellido'}\n\t\t\t  ]);\n\nvar cm = new cmodel({\n\t\t\t\t\tid : '',\n\t\t\t    nombre : '',\t\t\t \n\t\t\t  sucursal : '',\n\t\t\t  contacto : '',\n\t'sucursal::nombre' : '',\n  'contacto::apellido' : ''\n\t\t\t\t\t});\n\t\t\t\t\n\tgrid.stopEditing();\n\tstore.insert(0, cm);\n\tgrid.startEditing(0, 1);\n\n}\n\nvar eliminar = function(){\n\n\t\tvar noborrar = 0;\n\t\tvar m = grid.getSelections();\n        if( m.length > 0 )\n        {\n\t\t\tvar msg = 'Esta seguro que desea ' + ((m.length > 1)?'los':'el') + ' deposito' + ((m.length > 1)?'s':'') + '?';\n\t\t\n        \tExt.MessageBox.confirm('Emporika', msg , function( btn ){\n\t\t\t\t\tif( btn == 'yes' )\n\t\t\t\t\t{\t\n\t\t\t\t\t\tvar m = grid.getSelections();\n\t\t\t\t\t\tvar items = Array();\n\t\t\t\t\t\tfor( var i = 0, len = m.length; i < len; i++ ){  \t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tvar item = { id : m[i].get('id') }\n\t\t\t\t\t\t\t\titems.push( item );\t\t\t\t\t\t\t\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tvar pag = grid.getStore().lastOptions.params['start'];\t\t\t\t\t\t\n\t\t\t\t\t\tstore.load( { params : { \n\t\t\t\t\t\t\t\t\t\t\t\tstart : pag, \n\t\t\t\t\t\t\t\t\t\t\t\tlimit : {$page_size}, \n\t\t\t\t\t\t\t\t\t\t   DeleteData : Ext.encode(items) }\n\t\t\t\t\t\t\t\t\t});\t\t\n\t\t\t\t\t}\t\t\t\n\t\t\t});\t\n        }\n        else\n        {\n        \tExt.MessageBox.alert('Emporika', 'Por favor seleccione un deposito');\n        }\n}\n\nvar save = function(){\n\n\tvar hab = true;\n\tvar store_changes = store.getModifiedRecords();\n\tvar items = Array();\t\n\t\n\tfor( var i = 0, len = store_changes.length; i < len; i++ ){\n\t\n\t\t\t\t\n\t\tif( store_changes[i].get('nombre') == '' ){\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\tgrid.startEditing(i, 1);\n\t\t\thab = false;\n\t\t}\n\t\t\n\t\tif( store_changes[i].get('contacto') == '' && hab ){\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\tgrid.startEditing(i, 2);\n\t\t\thab = false;\n\t\t}\n\t\t\n\t\tif( store_changes[i].get('sucursal') == '' && hab ){\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\tgrid.startEditing(i, 3);\n\t\t\thab = false;\n\t\t}\n\t\t\n\t\t\t\n\t\tvar item = { \n\t\t\t\t\t id : store_changes[i].get('id'),\n\t\t\t     nombre : store_changes[i].get('nombre'),\n\t\t\t   contacto : store_changes[i].get('contacto::apellido'),\n\t\t\t   sucursal : store_changes[i].get('sucursal::nombre')\n\t\t\t\t   }\t\n\t\titems.push(item);\t\t   \n\t}\t\n\t\n\tif(hab){\n\t\tvar pag = grid.getStore().lastOptions.params['start'];\n\t\tstore.load( { params:{ \n\t\t\t\t\t\t\tstart : pag, \n\t\t\t\t\t\t\tlimit : {$page_size} , \n\t\t\t\t   NewsValuesData : Ext.encode(items) }\n\t\t\t\t   } );\n\t\tstore.commitChanges();\n\t}\n\t\n}\n\nvar button1 = grid.getTopToolbar().items.find( function(c){ return ( c.text == 'Nuevo') } );\nbutton1.on( 'click', nuevo );\n\nvar button2 = grid.getTopToolbar().items.find( function(c){ return ( c.text == 'Borrar') } );\nbutton2.on( 'click', eliminar );\n\nvar button3 = grid.getTopToolbar().items.find( function(c){ return ( c.text == 'Guardar cambios') } );\nbutton3.on( 'click', save );\n\n";
$grid->setEnableKeyEvents(true);
$grid->attachListener("render", new PhpExt_Listener(PhpExt_Javascript::functionDef(null, $grid_render, array("grid"))));
Ejemplo n.º 2
0
$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");
$store->setData(PhpExt_Javascript::variable("Ext.exampledata.states"));
$combo->setStore($store);
$fset->addItem($combo);
$fset->addItem(PhpExt_Form_DateField::createDateField("dob", "Data of Birth")->setAllowBlank(false));
$fs->addItem($fset);
$fs->addButton(PhpExt_Button::createTextButton("Load", new PhpExt_Handler(PhpExt_Javascript::stm("fs.getForm().load({url:'examples/form/xml-form.xml', waitMsg:'Loading',method: 'GET'})"))));
$submitBtn = PhpExt_Button::createTextButton("Submit", new PhpExt_Handler(PhpExt_Javascript::stm("fs.getForm().submit({url:'examples/form/xml-errors.xml', waitMsg:'Saving Data...'})")));
$fs->addButton($submitBtn);
//****************************** onReady
echo PhpExt_Ext::onReady(PhpExt_Javascript::stm(PhpExt_QuickTips::init()), PhpExt_Javascript::assign("Ext.form.Field.prototype.msgTarget", PhpExt_Javascript::valueToJavascript(PhpExt_Form_FormPanel::MSG_TARGET_SIDE)), $fs->getJavascript(false, "fs"), PhpExt_Javascript::assignNew("submit", $submitBtn->getJavascript()), $fs->render("form-ct"));
Ejemplo n.º 3
0
 public function __construct()
 {
     parent::__construct();
     $this->setExtClassInfo("Ext.form.TimeField", "timefield");
     $validProps = array("altFormat", "format", "increment", "invalidText", "maxText", "maxValue", "minText", "minValue");
     $this->addValidConfigProperties($validProps);
 }
Ejemplo n.º 4
0
 /**
  * Helper function to create a ComboBox.  Useful for quick adding it to a ComponentCollection
  *
  * @param string $name The field's HTML name attribute.
  * @param string $labelThe label text to display next to this field (defaults to '')
  * @param string $id The unique id of this component (defaults to an auto-assigned id).
  * @param string $hiddenName If specified, a hidden form field with this name is dynamically generated to store the field's data value (defaults to the underlying DOM element's name). Required for the combo's value to automatically post during a form submission.
  * @return PhpExt_Form_ComboBox
  */
 public static function createComboBox($name, $label = null, $id = null, $hiddenName = null)
 {
     $c = new PhpExt_Form_ComboBox();
     $c->setName($name);
     if ($label !== null) {
         $c->setFieldLabel($label);
     }
     if ($id !== null) {
         $c->setId($id);
     }
     if ($hiddenName !== null) {
         $c->setHiddenName($hiddenName);
     }
     return $c;
 }
Ejemplo n.º 5
0
//GRILLA
$grid = new PhpExt_Grid_GridPanel();
$grid->setStore($store)->setSelectionModel($check_select)->setColumnModel($col_model)->setLoadMask(true)->setenableColLock(false);
$grid->getPlugins()->add($filter_plugin);
$grid->getPlugins()->add(new PhpExtUx_App_FitToParent());
$grid_render = "\n\nvar combo = grid.getTopToolbar().items.find( function(c){ return ( c.xtype == 'combo') } );\nvar store = grid.getStore();\n\n\tvar nuevo = function(){\n\t\tvar id = 'gid=' + grid.id ;\n\t\taddTab( 'Nuevo Usuario', '/seguridad/user/new', true, id );\n\t}\n\nvar edit = function(){\n\t\n\t\t\tvar id;\n\t\t\tvar m = grid.getSelections();\n\n\t\t\tif( m.length >= 1 ){\t\n\t\t\t\tfor( var i = 0, len = m.length; i < len; i++ ){\t\t\t\t\t\n\t\t\t\t\t\tvar id = 'id=' + m[i].get('id') + '&gid=' + grid.id ;\n\t\t\t\t\t\taddTab('Modificar Usuario','/seguridad/user/update',true,id);\t\t\t\t\t\t\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tExt.MessageBox.alert('Emporika', 'Por favor seleccione un item');\n\t\t\t}\t\t\t\n}\n\n\tvar save = function(){\n\t\n\tif( combo.getValue() == '' ){\n\t\tExt.Msg.alert('Nutus Econom&iacute;a', 'Debe seleccionar un estado' );\t\n\t}\n\telse\n\t{\n\t\n\t\tvar m = grid.getSelections();\n        if(m.length > 0)\n        {\n        \tExt.MessageBox.confirm( 'Emporika', 'Esta seguro que desea cambiar el estado?' , function(btn){\n\t\t\t\t\n\t\t\t\tif( btn == 'yes' ){\t\n\t\t\t\t\tvar m = grid.getSelections();\n\t\t\t\t\t\n\t\t\t\t\tvar items = Array();\n\t\t\t\t\tfor(var i = 0, len = m.length; i < len; i++){  \n\t\t\t\t\t\tvar item = { id : m[i].get('id') };\n\t\t\t\t\t\titems.push(item);\n\t\t\t\t\t}\n\t\t\t\t\tvar json = { \n\t\t\t\t\t\t\t\t status : combo.getRawValue() ,\n\t\t\t\t\t\t\t\t  items : items\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t   }\t\t\t\t\t\n\t\t\t\t\t\t   \n\t\t\t\t\tvar pag = grid.getStore().lastOptions.params['start'];\n\t\t\t\t\tgrid.getStore().load( { params : { start : pag, limit: {$page_size} , UpdateStateData: Ext.encode(json) } } );\t\t\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}, this );\t\n        }\n        else\n        {\n        \tExt.MessageBox.alert('Emporika', 'Por favor seleccione un item');\n        }\n\n\t}\n\t\n\t}\n\n\nvar eliminar = function(){\n\t\n\tvar m = grid.getSelections();\n        if(m.length > 0)\n        {\n\t\t\tvar msg = 'Esta seguro que desea eliminar ' + ((m.length>1)?'los':'el') + ' usuario' + ((m.length>1)?'s':'') + '?';\n        \tExt.MessageBox.confirm('Emporika', msg , \n\t\t\tfunction(btn){\n\t\t\t\t\tif( btn == 'yes' ){\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tvar items = Array();\n\t\t\t\t\t\t\tfor(var i = 0, len = m.length; i < len; i++){  \n\t\t\t\t\t\t\t\tvar item = { id: m[i].get('id') };\n\t\t\t\t\t\t\t\titems.push( item );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tvar pag = grid.getStore().lastOptions.params['start'];\t\n\t\t\t\t\t\t\tstore.load( { params:{ \n\t\t\t\t\t\t\t\t\t\t\t\tstart: pag,\n\t\t\t\t\t\t\t\t\t\t\t\tlimit: {$page_size} , \n\t\t\t\t\t\t\t\t\t\tDeleteUserData: Ext.encode(items) \n\t\t\t\t\t\t\t\t\t\t\t\t}\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t  });\t\t\n\t\t\t\t\t}\t\t\n\t\t\t}, this );\t\n        }\n        else\n        {\n        \tExt.MessageBox.alert('Emporika', 'Por favor seleccione un item');\n        }\n}\t\n\t\nvar button1 = grid.getTopToolbar().items.find( function(c){ return ( c.text == 'Nuevo') } );\nbutton1.on( 'click', nuevo );\n\nvar button2 = grid.getTopToolbar().items.find( function(c){ return ( c.text == 'Modificar') } );\nbutton2.on( 'click', edit );\n\nvar button3 = grid.getTopToolbar().items.find( function(c){ return ( c.text == 'Guardar cambios') } );\nbutton3.on( 'click', save );\n\nvar button4 = grid.getTopToolbar().items.find( function(c){ return ( c.text == 'Eliminar') } );\nbutton4.on( 'click', eliminar );\n\ngrid.on( 'celldblclick', edit );\n\n";
$grid->setEnableKeyEvents(true);
$grid->attachListener("render", new PhpExt_Listener(PhpExt_Javascript::functionDef(null, $grid_render, array("grid"))));
//SETEO LA BARRA DE PAGINACION
$grid->setBottomToolbar($paging);
//Data_Store para llenar el combo con los datos
$store_estados = new PhpExt_Data_SimpleStore();
$store_estados->addField("id");
$store_estados->addField("descripcion");
$store_estados->setData(PhpExt_Javascript::variable(json_encode($estados)));
$cbo_estados = PhpExt_Form_ComboBox::createComboBox(null, "Estado")->setWidth(80)->setStore($store_estados)->setDisplayField("descripcion")->setValueField("id")->setEditable(false)->setForceSelection(true)->setSingleSelect(true)->setEmptyText("seleccionar")->setMode(PhpExt_Form_ComboBox::MODE_LOCAL)->setTriggerAction(PhpExt_Form_ComboBox::TRIGGER_ACTION_ALL);
$txt_busqueda = new PhpExtUx_App_SearchField();
$txt_busqueda->setStore($store);
$tb = $grid->getTopToolbar();
$tb->addButton("new", "Nuevo", "images/add.png");
$tb->addSeparator("sep1");
$tb->addButton("modificar", "Modificar", "images/edit.gif");
$tb->addSeparator("sep2");
$tb->addButton("delete", "Eliminar", "images/no_.gif");
$tb->addSeparator("sep3");
$tb->addTextItem("text2", "Buscar:");
$tb->addItem("txt_busqueda", $txt_busqueda);
$tb->addFill("fill");
$tb->addTextItem("text", "Modificar estado:");
$tb->addItem("estados", $cbo_estados);
$tb->addButton("guardar", "Guardar cambios", "images/save.gif");
Ejemplo n.º 6
0
include_once 'PhpExt/Form/TextField.php';
include_once 'PhpExt/Form/NumberField.php';
include_once 'PhpExt/Form/DateField.php';
include_once 'PhpExt/Form/ComboBox.php';
include_once 'PhpExtUx/Grid/CheckColumn.php';
$formatDate = PhpExt_Javascript::functionDef("formatDate", "return value ? value.dateFormat('M d, Y') : '';", array("value"));
// custom column plugin example
$checkColumn = new PhpExtUx_Grid_CheckColumn("Indoor?");
$checkColumn->setDataIndex("indoor");
$checkColumn->setWidth(55);
// the column model has information about grid columns
//dataIndex maps the column to the specific data field in
// the data store (created below)
// ColumnModel
$txtCommon = PhpExt_Form_TextField::createTextField('txtCommon')->setAllowBlank(false);
$cmbLight = PhpExt_Form_ComboBox::createComboBox("cmbLight")->setTypeAhead(true)->setTriggerAction(PhpExt_Form_ComboBox::TRIGGER_ACTION_ALL)->setTransform("light")->setLazyRender(true)->setListCssClass('x-combo-list-small');
$txtPrice = PhpExt_Form_NumberField::createNumberField("txtPrice")->setAllowBlank(false)->setAllowNegative(false)->setMaxValue(100000);
$dtAvailable = PhpExt_Form_DateField::createDateField("dtAvaliable")->setFormat("m/d/y")->setMinValue("01/01/06")->setDisabledDays(array(0, 6))->setDisabledDaysText("Plants are not available on the weekends");
$colModel = new PhpExt_Grid_ColumnModel();
$colModel->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Common Name", "common", "common", 220)->setEditor($txtCommon))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Light", "light", null, 130)->setEditor($cmbLight))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Price", "price", "price", 70, PhpExt_Ext::HALIGN_RIGHT, "usMoney")->setEditor($txtPrice))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Avaliable", "availDate", "availDate", 95, null, PhpExt_Javascript::variable('formatDate'))->setEditor($dtAvailable))->addColumn($checkColumn);
// this could be inline, but we want to define the Plant record
// type so we can add records dynamically
$fields = new PhpExt_Data_FieldConfigObjectCollection();
$fields->add(new PhpExt_Data_FieldConfigObject("common", null, PhpExt_Data_FieldConfigObject::TYPE_STRING));
$fields->add(new PhpExt_Data_FieldConfigObject("botanical", null, PhpExt_Data_FieldConfigObject::TYPE_STRING));
$fields->add(new PhpExt_Data_FieldConfigObject("light"));
$fields->add(new PhpExt_Data_FieldConfigObject("price", null, PhpExt_Data_FieldConfigObject::TYPE_FLOAT));
$fields->add(new PhpExt_Data_FieldConfigObject("availDate", "availability", PhpExt_Data_FieldConfigObject::TYPE_DATE, "m/d/Y"));
$fields->add(new PhpExt_Data_FieldConfigObject("indoor", null, PhpExt_Data_FieldConfigObject::TYPE_BOOLEAN));
$plant = PhpExt_Data_Record::create($fields);
// Reader
Ejemplo n.º 7
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/ScriptTagProxy.php';
include_once 'PhpExt/Data/JsonReader.php';
include_once 'PhpExt/Data/FieldConfigObject.php';
include_once 'PhpExt/Config/ConfigObject.php';
include_once 'PhpExt/XTemplate.php';
include_once 'PhpExt/Form/ComboBox.php';
include_once 'PhpExt/Listener.php';
$ds = new PhpExt_Data_Store();
$ds->setProxy(new PhpExt_Data_ScriptTagProxy('http://extjs.com/forum/topics-remote.php'));
$reader = new PhpExt_Data_JsonReader();
$reader->setRoot("topics")->setTotalProperty("totalCount")->setId("post_id");
$reader->addField(new PhpExt_Data_FieldConfigObject("postId", "post_id"));
$reader->addField(new PhpExt_Data_FieldConfigObject("title", "topic_title"));
$reader->addField(new PhpExt_Data_FieldConfigObject("topicId", "topic_id"));
$reader->addField(new PhpExt_Data_FieldConfigObject("author", "author"));
$reader->addField(new PhpExt_Data_FieldConfigObject("lastPost", "post_time", "date", "timestamp"));
$reader->addField(new PhpExt_Data_FieldConfigObject("excerpt", "post_text"));
$ds->setReader($reader);
$ds->setBaseParams(array("limit" => 20, "forumId" => 21));
$resultTpl = new PhpExt_XTemplate('<tpl for="."><div class="search-item">', '<h3><span>{lastPost:date("M j, Y")}<br />by {author}</span>{title}</h3>', '{excerpt}', '</div></tpl>');
$search = new PhpExt_Form_ComboBox(null, "searchbox");
$search->setStore($ds)->setDisplayField("title")->setTypeAhead(false)->setLoadingText("Searching...")->setWidth(570)->setPageSize(10)->setHideTrigger(true)->setTemplate($resultTpl)->setApplyTo("fsearch")->setItemCssSelector("div.search-item")->attachListener("onSelect", new PhpExt_Listener(PhpExt_Javascript::functionDef(null, "window.location =\r\n                String.format('http://extjs.com/forum/showthread.php?t={0}&p={1}', record.data.topicId, record.id)", array("record"))));
//------------ Ext.OnReady
echo PhpExt_Ext::onReady($ds->getJavascript(false, "ds"), $resultTpl->getJavascript(false, "resultTpl"), $search->getJavascript(false, "search"));
Ejemplo n.º 8
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/SimpleStore.php';
include_once 'PhpExt/Data/FieldConfigObject.php';
include_once 'PhpExt/Form/ComboBox.php';
include_once 'PhpExt/QuickTips.php';
// simple array store
$store = new PhpExt_Data_SimpleStore();
$store->addField("abbr");
$store->addField("state");
$store->addField("nick");
$store->setData(PhpExt_Javascript::variable("Ext.exampledata.states"));
// from states.js
$combo = new PhpExt_Form_ComboBox();
$combo->setStore($store)->setDisplayField("state")->setTypeAhead(true)->setMode(PhpExt_Form_ComboBox::MODE_LOCAL)->setTriggerAction(PhpExt_Form_ComboBox::TRIGGER_ACTION_ALL)->setEmptyText("Select a state...")->setSelectOnFocus(true)->setApplyTo("local-states");
$comboWithTooltip = new PhpExt_Form_ComboBox();
$comboWithTooltip->setTemplate('<tpl for="."><div ext:qtip="{state}. {nick}" class="x-combo-list-item">{state}</div></tpl>')->setStore($store)->setDisplayField("state")->setTypeAhead(true)->setMode(PhpExt_Form_ComboBox::MODE_LOCAL)->setTriggerAction(PhpExt_Form_ComboBox::TRIGGER_ACTION_ALL)->setEmptyText("Select a state...")->setSelectOnFocus(true)->setApplyTo("local-states-with-qtip");
$converted = new PhpExt_Form_ComboBox();
$converted->setTypeAhead(true)->setTriggerAction(PhpExt_Form_ComboBox::TRIGGER_ACTION_ALL)->setTransform("state")->setWidth(135)->setForceSelection(true);
echo PhpExt_Ext::onReady(PhpExt_Javascript::stm(PhpExt_QuickTips::init()), $store->getJavascript(false, "store"), $combo->getJavascript(false, "combo"), $comboWithTooltip->getJavascript(false, "comboWithTooltip"), $converted->getJavascript(false, "converted"));