Ver Mensaje Individual
  #4 (permalink)  
Antiguo 08/08/2011, 14:52
Fenris
 
Fecha de Ingreso: agosto-2008
Mensajes: 271
Antigüedad: 15 años, 8 meses
Puntos: 2
Respuesta: Consulta:Zend + JQgrid

SOLUCIONADO!!!

Gracias Masterpuppet,

La verdad es que ya habia revisado esa pagina, y claro como esta en version alpha aun no implementa funciones de insercion, modificacion o eliminacion.
He estado leyendo algunos articulos y he conseguido hacer algo recordando algo que ya habia hecho con ajax utilizando Zend Framework pero al momento de visualizar la grilla me muestra los datos en forma de texto debajo de esta como impresos y no dentro de la grilla.

Muestro el codigo

Controlador
Código PHP:
Ver original
  1. public function init()
  2.     {
  3.         /* Initialize action controller here */
  4.        
  5.         $contextSwitch = $this->_helper->getHelper('contextSwitch');
  6.         $contextSwitch->addActionContext('index', 'json')
  7.                       ->setAutoJsonSerialization(false)
  8.                       ->initContext();
  9.     }
  10.  
  11.     public function indexAction()
  12.     {
  13.         // action body
  14.         $this->_helper->layout->disableLayout();
  15.         $this->view->title = "Patologias";
  16.         $patologia = new Application_Model_Patologias();
  17.     echo $patologia->fetchAll();
  18.        
  19.     }

Modelo
Código PHP:
Ver original
  1. public function fetchAll()
  2.     {
  3.         $resultSet = $this->getDbTable()->fetchAll();
  4.         $entries   = array();
  5.        
  6.         $response = new stdClass();
  7.         $response->page =1;
  8.         $response->total = 1;
  9.         $response->records = $this->total();
  10.         $i=0;
  11.         foreach ($resultSet as $row){
  12.             $response->rows[$i]['idPatologia'] = $row->idPatologia;
  13.             $response->rows[$i]['descripcion'] = $row->descripcion;
  14.         $i++;
  15.         }
  16.        
  17.         return json_encode($response);
  18.     }

View index.phtml

Código HTML:
Ver original
  1. <?php echo $this->doctype() ?>
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  4.  
  5. <?php $this->headLink()->appendStylesheet('/css/global.css') ?>
  6. <?php $this->headLink()->appendStylesheet('/css/master.css') ?>
  7. <?php $this->headLink()->appendStylesheet('/css/redmond/jquery.ui.all.css') ?>
  8. <?php $this->headLink()->appendStylesheet('/css/ui.jqgrid.css') ?>
  9.  
  10. <?php echo $this->headLink() ?>
  11. <script type="text/javascript" src="/js/funciones.js"></script>
  12. <script type="text/javascript" src="/js/jquery-1.4.4.min.js"></script>
  13. <script type="text/javascript" src="/js/jquery-ui-1.8.9.custom.min.js"></script>
  14. <script src="/js/i18n/grid.locale-es.js" type="text/javascript"></script>
  15. <script src="/js/jquery.jqGrid.min.js" type="text/javascript"></script>
  16.  
  17. <script type="text/javascript">
  18. $(document).ready(function(){
  19. jQuery("#grid").jqGrid({
  20.     url:'/patologias/index/format/json',
  21.     datatype: "json",
  22.     colNames:['IdPatologia','Descripcion'],
  23.     colModel:[
  24.         {name:'idPatologia',index:'idPatologia', width:200, editable:false, editoptions:{readonly:true}, sorttype:'int'},
  25.         {name:'descripcion',index:'descripcion', width:350, sortable:false, editable:true}
  26.     ],
  27.     rowNum:10,
  28.     rowTotal: 50,
  29.     rowList:[10,20,30],
  30.     pager: '#pager',
  31.     sortname: 'idPatologia',
  32.     loadonce: true,
  33.     viewrecords: true,
  34.     sortorder: "desc",
  35.     editurl: '/patologias/edit', // this is dummy existing url
  36.     caption:"Patologias"
  37. });
  38. jQuery("#grid").jqGrid('navGrid','#pager',{});
  39.  
  40. });
  41. </head>
  42. <table id="grid"><tr><td>&nbsp;</td></tr></table>
  43. <div id="pager"></div>
  44. </body>
  45. </html>

contextSwitch Vista index.json.phtml
Código PHP:
Ver original
  1. <?php echo json_decode($this->response); ?>

Espero me puedan orientar o decir donde esta el problema.

Saludos

Última edición por Fenris; 16/08/2011 a las 08:06