Saturday, April 28, 2012

Re: CakePHP 2 + JQuery Easy UI

hi, chopite, tries with this code:
 

 function getPaises(){
   
       $paises = $this->Pais->find(
           'all',
           array(
               'fields'=>array(
                   'Pais.id',
                   'Pais.nombre'
               )
           )
       );

$this->set('return',$paises);
$this->render('getPaises','ajax');
  }
  
  

in /View/{Controller}/get_paises.ctp , only this code:

<?php 
if(isset($return)){
echo json_encode($return);
?>


2012/4/28 wchopite <wchopite@gmail.com>
Hi people, I´m from Venezuela sorry my english.

I have a little problem and I need your help

I need to work with Jquery Easy UI (http://www.jeasyui.com) and with
Cakephp together.

But I can´t do it work.

I make the query in the controller and return the data in Json format:

 function getPaises(){
       $this->autoRender= false;
       Configure::write('debug', 0);

       $paises = $this->Pais->find(
           'all',
           array(
               'fields'=>array(
                   'Pais.id',
                   'Pais.nombre'
               )
           )
       );

       return (json_encode($paises));
   }

In view, I have:

<table id="tt"></table>


<input type="hidden" id="url-listado-paises" value="<?php echo $this-
>Html->url(array('controller'=>'paises','action'=>'getPaises')); ?>"/>

<script>
   $('#tt').datagrid({
       url:$('#url-listado-paises').val(),
       columns:[[
           {
               'Pais': {
                   field:'id',title:'ID',width:100,
                   field:'nombre','title':'Nombre'
               }
           }
       ]]
   });
</script>

But it doesn´t work

Any idea why?

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: