Пример #1
0
$txt_nuevo_valor = new PhpExt_Form_NumberField();
$txt_nuevo_valor->setDecimalSeparator($separador_decimal)->setMsgTarget(PhpExt_Form_FormPanel::MSG_TARGET_SIDE);
//AGREGO LAS COLUMNAS A LA GRILLA
$col_model = new PhpExt_Grid_ColumnModel();
$col_model->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Id", "id", null, 35));
$col_model->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Moneda", "currency"));
$col_model->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Ultimo Valor", "value"));
$col_model->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Fecha", "date", null, 110));
$col_model->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Nuevo Valor", "new")->setEditor($txt_nuevo_valor));
$paging = new PhpExt_Toolbar_PagingToolbar();
$paging->setStore($store)->setDisplayInfo(true)->setEmptyMessage("No tiene monedas flotantes para definir el tipo de cambio");
//GRILLA
$grid = new PhpExt_Grid_EditorGridPanel();
$grid->setStore($store)->setColumnModel($col_model)->setSelectionModel(new PhpExt_Grid_RowSelectionModel())->setLoadMask(true)->setenableColLock(false);
$grid->setBottomToolbar($paging);
$grid->getPlugins()->add(new PhpExtUx_App_FitToParent());
$grid_render = "\n\n\nvar save = function(){\n\tvar fecha = grid.getTopToolbar().items.find( function(c){ return (c.xtype == 'datefield') } );\t\n\tvar store = grid.getStore();\n\tvar store_changes = store.getModifiedRecords();\n\t\n\tvar items = Array();\n\t\n\tfor( var i = 0, len = store_changes.length; i < len; i++ )\n\t{\t\t\n\t\tvar item = { \n\t\t\t\t\t id : store_changes[i].get('id'),\n\t\t\t\t  value : store_changes[i].get('new')\t\t\t\t\t\n\t\t           }\n\t\titems.push(item);\n\t}\n\t\n\tvar json = { \n\t\t\t\t fecha : fecha.value,\n\t\t\t\t items : items \n\t\t\t   }\n\t\n\tstore.load( { params:{ NewsValuesData : Ext.encode(json) } } );\n\tstore.commitChanges();\n\t\n\t\n}\n\t\nvar button1 = grid.getTopToolbar().items.find( function(c){ return ( c.text == 'Guardar cambios') } );\nbutton1.on( 'click', save );\n\n";
$grid->setEnableKeyEvents(true);
$grid->attachListener("render", new PhpExt_Listener(PhpExt_Javascript::functionDef(null, $grid_render, array("grid"))));
//CONTROL PARA LA FECHA
$txt_fecha = new PhpExt_Form_DateField();
$txt_fecha->setInvalidText("Fecha Invalida(dd/mm/yyyy)")->setValue(date('Y-m-d'))->setFormat(str_replace("%", "", $ari->get("locale")->get('shortdateformat', 'datetime')));
$tb = $grid->getTopToolbar();
$tb->addTextItem("text", "Fecha:");
$tb->addItem("txt_fecha", $txt_fecha);
$tb->addButton("update", "Guardar cambios", "images/save.gif");
$resultado = '';
$resultado .= $store->getJavascript(false, "store_user_list");
$resultado .= $col_model->getJavascript(false, "cm");
$resultado .= $grid->getJavascript(false, "contenido");
$resultado .= "store_user_list.load();";
Пример #2
0
//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&oacute;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"))));
$tb = $grid->getTopToolbar();
$tb->addButton("new", "Nuevo", "images/add.png");
$tb->addSeparator("sep1");
$tb->addButton("delete", "Borrar", "images/no_.gif");
$tb->addSeparator("sep2");
$tb->addButton("update", "Guardar cambios", "images/save.gif");
$resultado = '';
$resultado .= $store->getJavascript(false, "store_sucursales_list");
$resultado .= " store_sucursales_list.load( { params : { start : 0, limit : {$page_size} } } );";
$resultado .= $filter_plugin->getJavascript(false, "filters");
Пример #3
0
// 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
$reader = new PhpExt_Data_XmlReader();
$reader->setRecord("plant");
$reader->setRecordType("Plant");
// Store
$store = new PhpExt_Data_Store();
$store->setUrl("examples/grid/plants.xml")->setReader($reader)->setSortInfo(new PhpExt_Data_SortInfoConfigObject("common"));
// Grid
$grid = new PhpExt_Grid_EditorGridPanel();
$grid->setClicksToEdit(1)->setStore($store)->setColumnModel($colModel)->setAutoExpandColumn("common")->setFrame(true)->setHeight(300)->setWidth(600)->setTitle("Edit Plants?")->setRenderTo("editor-grid");
$grid->getPlugins()->add($checkColumn);
$grid->getTopToolbar()->addButton("add", "Add Plant", null, new PhpExt_Handler(PhpExt_Javascript::inlineStm("var p = new Plant({\r\n            common: 'New Plant 1',\r\n            light: 'Mostly Shade',\r\n            price: 0,\r\n            availDate: (new Date()).clearTime(),\r\n            indoor: false\r\n        });\r\n        grid.stopEditing();\r\n        store.insert(0, p);\r\n        grid.startEditing(0, 0);")));
// Ext.OnReady -----------------------
echo PhpExt_Ext::onReady(PhpExt_QuickTips::init(), $formatDate, $checkColumn->getJavascript(false, "checkColumn"), $colModel->getJavascript(false, "cm"), PhpExt_Javascript::assignNew("Plant", $plant), $store->getJavascript(false, "store"), $grid->getJavascript(false, "grid"), $store->load());