Beispiel #1
0
$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();
$button_toolbar->addButton("save_changes", "Guardar Cambios", "images/save.gif");
$button_toolbar->addButton("refresh", "Actualizar Lista", "images/Refresh.gif");
//SE DEVUELVEN LOS RESULTADOS
$resultado = '';
$resultado .= $checkColumn->getJavascript(false, "checkColumn");
$resultado .= $store->getJavascript(false, "store_user_list");
$resultado .= $col_model->getJavascript(false, "cm");
$resultado .= $grid->getJavascript(false, "contenido");
//RESULTADO
$obj_comunication = new OOB_ext_comunication();
$obj_comunication->set_data($resultado);
$obj_comunication->send(true);
Beispiel #2
0
$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");
//resultados
$resultado = '';
$resultado .= $check_select->getJavascript(false, "sm");