Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
Gray div and empty grid...
03/11/2010
00:42
Avatar
Rbn_3D
New Member
Members
Forum Posts: 2
Member Since:
03/11/2010
sp_UserOfflineSmall Offline

Hi, I'm trying to populate my grid using json, managed by php. The json response is ok, I see it in firebug. But it looks like loading, the overlay div never dissapears, and the grid is empty. (I don't receive javascript errors)

I'm using the lastest version (3.8.1)

My javascript code:

<script type="text/javascript">
$(document).ready(function(){
  $("#grid_recibidos").jqGrid({
    url:'admin/json_grid.php?q=grid_recibidos',
    datatype: 'json',
    mtype: 'POST',
    colNames:['ID','E-mail', 'Nombre','Mensaje','Respondido','Fecha'],
    colModel :[
      {name:'id', index:'id', width:55, jsonmap:"id"},
      {name:'email', index:'email', width:90, jsonmap:"email"},
      {name:'nombre', index:'nombre', width:80, align:'right', jsonmap:"nombre"},
      {name:'mensaje', index:'mensaje', width:80, align:'right', jsonmap:"mensaje"},
      {name:'respondido', index:'respondido', width:80, align:'right', jsonmap:"respondido"},
      {name:'fecha', index:'fecha', width:150, sortable:true, jsonmap:"fecha"}
    ],
    pager: '#grid_recibidos_pager',
    rowNum:10,
    rowList:[10,20,30],
    sortname: 'fecha',
    sortorder: 'desc',
    viewrecords: true,
    caption: 'Mensajes recibidos'
  });
});
</script>

And the json response:

{"page":1,"total":1,"records":2,"rows":[{"id":0,"cell":{"id":"1","email":"rgsrh","nombre": "sdgh","mensaje":"stdfjh","respondido":"0","fecha" :"2010-11-02"}},{"id":1,"cell":{"id":"2","email":"hhhh","nom bre":"jjj","mensaje":"kkk","respondido":"0","fecha ":"2010-11-02"}}]}

Any ideas?? Thanks

03/11/2010
01:05
Avatar
Rbn_3D
New Member
Members
Forum Posts: 2
Member Since:
03/11/2010
sp_UserOfflineSmall Offline

The overlay div was a problem with a missing css, it's fixed, but the grid are still empty, the rows are rendered ok, but whitout any text...

03/11/2010
12:08
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

I recommend you to read documentation about preparing of JSON data on the server. Currently you use a mix between different ways. To be able to display the data prepared in the form you should add "cell." prefix to all jsonmap values:

colModel: [
    { name: 'id', index: 'id', width: 55, jsonmap: "cell.id" },
    { name: 'email', index: 'email', width: 90, jsonmap: "cell.email" },
    { name: 'nombre', index: 'nombre', width: 80, align: 'right', jsonmap: "cell.nombre" },
    { name: 'mensaje', index: 'mensaje', width: 80, align: 'right', jsonmap: "cell.mensaje" },
    { name: 'respondido', index: 'respondido', width: 80, align: 'right', jsonmap: "cell.respondido" },
    { name: 'fecha', index: 'fecha', width: 150, sortable: true, jsonmap: "cell.fecha" }
],

 

and include additional parameter jsonReader: { repeatitems: false }. But after all the changes you will see not full data send from the server because the second line contains 

{"id":"2","email":"hhhh","nom bre":"jjj","mensaje":"kkk","respondido":"0","fecha ":"2010-11-02"}

instead of

{"id":"2","email":"hhhh","nombre":"jjj","mensaje":"kkk","respondido":"0","fecha":"2010-11-02"}

I don't recommend you to do manual serialization to JSON data any time. Currently there are standard methods for the purpose.

Best regards
Oleg

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
59 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information