Skip to content Skip to sidebar Skip to footer

Jqgrid Not Showing Rows, Only Shows Total Number Of Rows

I'm having a problem that I can't sort it out. Please take a look at this image first As you can see, I have been able to request the JSON data from server. The pager shows that t

Solution 1:

I agree with Briguy37 that the value "total": 0 is strange and of cause incorrect. Nevertheless jqGrid should do display all data.

I suppose that you have the problem in the part of your code which you not posted here. How you can see from the demo the code which you posted can do read and display the JSON data.

Solution 2:

Here's a couple issues...haven't figured out why your results aren't getting populated yet, though:

Total in your returned JSON should be the number of pages. Because it is set to 0, that is why it is displaying 0. Also, you'll probably want to return rowCount as 10 in case you change the number of results per page.

Solution 3:

You are missing a json reader, I had the exact same problem.

$("#list").jqGrid({
url : "my-json-table-action' />",
datatype: 'json',
jsonReader: {
root: 'gridModel',
id: 'idTT',
repeatitems: false,
},
resize: false,
hidegrid: false,
data: 'trabajosTerminales',
mtype: 'POST',
height: 'auto',
colNames:['No. de Registro', 'Título', 'Tipo', 'Periodo'],
colModel :[ 
{name:'numRegistro', index:'titulo', search: 'true', stype:'text', align:'center' searchrules:{required:true},  width:100  },
{name:'titulo', key:'true', index:'titulo', search: 'true', stype:'text',        searchrules:{required:true},  width:800  },
{name:'tipo', key:'true', index:'tipo', search: 'true', stype:'text',align:'center', searchrules:{required:true},  width:100  },
{name:'periodo', key:'true', index:'titulo', search: 'true', stype:'text', searchrules:{required:true},  width:100  },
],
pager: '#pager', 
rowNum:10,
rowList:[10,20,30],
viewrecords: true,
gridview: true,
caption: 'Trabajos Terminales dirigidos',
}); 

jQuery("#list").navGrid('#pager',{edit:false,add:false,del:false});     
}); 

Where the root element is the array that contains your data, in this case I'm returning my data in an array called 'gridModel', the id is not necessary. But you have to make sure to set the root element right, in your case it's called 'rows' instead 'gridModel'.

Post a Comment for "Jqgrid Not Showing Rows, Only Shows Total Number Of Rows"