Forum

July 10th, 2011
You must be logged in to post Login Register

Search Forums:


 






renderGrid() only displays first row

UserPost

19:40
22/08/2011


itsame69

New Member

posts 2


Hi,


I am evaluating jqGrid for a project that we are currently working on. The first task is to integrate jqSuite for PHP into a Zend Framework project. After some debugging this works.


However, I'm currently having the following problem: I'm using the following lines of code (in my Controller) to initialize jqGrid:


        $this->_gridConn = new PDO(DB_DSN,DB_USER,DB_PASSWORD);
        $this->_grid = new jqGridRender($this->_gridConn);
        $this->_grid->SelectCommand = 'SELECT id, firma, vorname, nachname, telefon, plz, ort FROM b_kunden';
        $this->_grid->table = 'b_kunden';
        $this->_grid->dataType = 'json';
        $this->_grid->setPrimaryKeyId('id');
        $this->_grid->setColModel();
        $this->_grid->setUrl('/kunden/fetchdata');
        $this->_grid->setGridOptions(array(
            "rowNum"=>10,
            "rowList"=>array(10,20,30),
            "sortname"=>"id"
        ));
        $this->_grid->setColProperty('id', array("editoptions"=>array("readonly"=>true)));
        $this->_grid->navigator = true;
        $this->_grid->setNavOptions('navigator', array("excel"=>false,"add"=>true,"edit"=>true,"del"=>true,"view"=>true, "search"=>true));
        $this->_grid->setNavOptions('edit',array("closeAfterEdit"=>true,"editCaption"=>"Update Customer","bSubmit"=>"Update"));
        $this->view->grid = $this->_grid;

The corresponding view simply renders the Grid:


<?php $this->grid->renderGrid('#grid','#pager',true, null, null, true,true); ?>


And last but not least, this Action returns the data:


         $rows = array('0' => array('id' => '1', 'firma' => 'test', 'vorname' => 'Christian', 'nachname' => 'Meier', 'telefon' => '+43 699 66666666', 'plz' => '9020', 'ort' => 'Klagenfurt'),
                      '1' => array('id' => '21', 'firma' => 'test', 'vorname' => 'Andreas', 'nachname' => 'Dreier', 'telefon' => '+43 699 66666666', 'plz' => '9020', 'ort' => 'Klagenfurt'),
                      '2' => array('id' => '2', 'firma' => 'test', 'vorname' => 'Hubert', 'nachname' => 'Feier', 'telefon' => '+43 699 66666666', 'plz' => '9020', 'ort' => 'Klagenfurt'),
                       '3' => array('id' => '13', 'firma' => 'test', 'vorname' => 'Horst', 'nachname' => 'Heier', 'telefon' => '+43 699 66666666', 'plz' => '9020', 'ort' => 'Klagenfurt'));

        $response['page'] = 1;
        $response['total'] = 1;
        $response['records'] = 3;
        $i=0;
        foreach ($rows as $r) {
            $response['rows'][$i]['id']=$r['id']; //id
            $response['rows'][$i]['cell']=array($r['id'],$r['firma'],$r['vorname'],$r['nachname'],$r['telefon'],$r['plz'],$r['ort']);
            $i++;
        }
        echo Zend_Json::encode($response);


The problem is, that this renders something like:

As you can see, the ID is displayed but all the other data is missing (i.e. not rendered). Any help or hint would be appreciated very much!


Thanks

      Christian

19:58
22/08/2011


itsame69

New Member

posts 2

Solved the problem. Actually, I simply forgot to define the jsonReader using setGridOption().

11:56
27/09/2012


bailamj

Member

posts 3

Can you  put the code correctly?

I have this problem but.. nothing…


About the jQuery Grid Plugin – jqGrid forum

Most Users Ever Online:

215


Currently Online:

49 Guests

Forum Stats:

Groups: 1

Forums: 7

Topics: 10276

Posts: 30365

Membership:

There are 11039 Members

There have been 448 Guests

There is 1 Admin

There are 2 Moderators

Top Posters:

OlegK – 1210

markw65 – 179

kobruleht – 144

phicarre – 132

YamilBracho – 124

Renso – 118

Administrators: admin (60 Posts)

Moderators: tony (7383 Posts), Rumen[Trirand] (81 Posts)




Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information