PhpExt_Javascript::sendContentType(); global $ari; $ari->popup = 1; // no mostrar el main_frame //STORE PARA TRAER EL LISTADO DE MODULOS $store = new PhpExt_Data_JsonStore(); $store->setUrl("/admin/module/get_modules")->setRoot("topics")->setAutoLoad(true)->setTotalProperty("totalCount"); //AGREGO LOS CAMPOS AL STORE $store->addField(new PhpExt_Data_FieldConfigObject("nicename")); $store->addField(new PhpExt_Data_FieldConfigObject("modulename")); $store->addField(new PhpExt_Data_FieldConfigObject("description")); $store->addField(new PhpExt_Data_FieldConfigObject("checked")); $store->addField(new PhpExt_Data_FieldConfigObject("optional")); //CHECKBOX PARA SELECCIONAR LOS MODULOS $checkColumn = new PhpExtUx_Grid_CheckColumn("Habilitado"); $checkColumn->setDataIndex("checked")->setId("check")->setWidth(55); //AGREGO LAS COLUMNAS A LA GRILLA $col_model = new PhpExt_Grid_ColumnModel(); $col_model->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Nombre del Módulo", "nicename", null, 150)); $col_model->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Descripción", "description", null, 340)); $col_model->addColumn($checkColumn); //GRILLA $grid = new PhpExt_Grid_GridPanel(); $grid->setStore($store)->setColumnModel($col_model)->setLoadMask(true)->setenableColLock(false); $grid->getPlugins()->add($checkColumn); $grid->getPlugins()->add(new PhpExtUx_App_FitToParent()); $grid_render = "\n\nvar store = grid.getStore();\n\ngrid.on( 'afteredit', function(e){\n\t\tvar datos = e.record.data;\n\t\tif(!datos.optional){\n\t\t\te.record.set( 'checked', true );\t\n\t\t\te.record.commit();\n\t\t}\n});\n\nvar save = function(){\n\t\n\tvar store_changes = store.getModifiedRecords();\n\tvar items = Array();\t\n\tfor(var i = 0, len = store_changes.length; i < len; i++){\n\t\tvar item = { \n\t\t\t\t modulename : store_changes[i].get('modulename'),\n\t\t\t\t\t checked : store_changes[i].get('checked')\n\t\t\t\t\t}\n\t\titems.push(item);\n\t}\t\n\tstore.load( {params : { UpdateEnabledData : Ext.encode(items) } } );\n\tstore.commitChanges();\n\n}\n\nvar refresh = function(){\n\tstore.load( {params : {UpdateList:true} } );\n}\n\nvar button1 = grid.getTopToolbar().items.find( function(c){ return ( c.text == 'Guardar Cambios') } );\nbutton1.on( 'click', save );\n\nvar button2 = grid.getTopToolbar().items.find( function(c){ return ( c.text == 'Actualizar Lista') } );\nbutton2.on( 'click', refresh );\n\n\n"; $grid->setEnableKeyEvents(true); $grid->attachListener("render", new PhpExt_Listener(PhpExt_Javascript::functionDef(null, $grid_render, array("grid")))); //BOTON PARA GUARDAR LOS CAMBIOS HECHOS EN LA GRILLA $button_toolbar = $grid->getTopToolbar();
include_once 'PhpExt/Data/Store.php'; include_once 'PhpExt/Data/XmlReader.php'; include_once 'PhpExt/Data/FieldConfigObject.php'; include_once 'PhpExt/Data/SortInfoConfigObject.php'; include_once 'PhpExt/Grid/ColumnModel.php'; include_once 'PhpExt/Grid/ColumnConfigObject.php'; include_once 'PhpExt/Grid/EditorGridPanel.php'; 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));