Forum
19:56
06/10/2014
Hi
Spec : JQGRID : 1.11.0 , JQuery :  2.1.0 , Browsers : FFOX :32.x, JSON Frmt : Gson ( java ) , Java : 1.7 ,
AppServ : Tomcat 8
Note : I have studied the API docs , Googled /yahooed .... for the process .... but not staisfied answer
Question  i have a JQGrid written down simple (static col defined ) trying to insert Array Data dynamically Colmns using JSON data format
<script type="text/javascript">
jQuery(document).ready(function () {
  Â
$("#list3").jqGrid({
colNames:['NO','IDNUM','PROTCL','DESC'],
colModel:[
{name:'NO',index:'true',width:'15',sortable:'true',align:'left',editable: true},
{name:'IDNUM',index:'true',width:'15',sortable:'true',align:'left',editable: true},
{name:'PROTCL',index:'true',width:'15',sortable:'true',align:'left',editable: true},
{name:'DESC',index:'true',width:'50',sortable:'true',align:'left',editable: true}
],
url : "Dummy.jsp",
hidegrid : false,
datatype : "jsonstring",
mtype : "GET",
loadonce : "true",
caption : "'Grid from Database using jsonstring'",
shrinkToFit : true,
autowidth : true,
width : "1300",
height : "125",
rowNum : "10",
rowList : [10,50,100],
sortorder : "desc",
viewrecords : true,
gridview : true,
autoencode : true,
multiselect : false,
loadtext : "Data-Organized",
pager : "table3",
}).jqGrid('navGrid','#list3',{edit:true,add:true,del:true,search:true});
var data = {
       "total": "1",
       "page": "1",
       "records": "2",
       "rows" : [
         {"id" :"1", "cell" :["cell11", "cell12", "cell13","cell13"]},
         {"id" :"2", "cell":["cell21", "cell22", "cell23","cell13"]},
       ]
      };
     Â
$("#list3")[0].addJSONData(eval(data));
 })
</script>
</head>
<body>
<table border=1Â id="list3" style="font-size:12px;">
<tr>
<td></td>
</tr>
</table>
<div id="<%=sigid3%>"></div>
</html>
I do not see Data but empty Grid lines.....
Is the JSON Data provided is faulty ?
Is usage of 'addJSONdata' not proper ?
Is the code written above not correct ?
Ref : I need to Supply the Dynamic Data to Static Cols Defined ONLY and cannot change to any other jqGrid process.
Â
Plz somebody enlighten me with the mistake in the code.
Â
with regards
karthik N.S
17:02
06/10/2014
Hi
as per the PDF provided
>>JSON data is handled in a fashion very similar to that of xml data. What is important is that the definition >> of the jsonReader matches the data being received datatype: json, (or jsonstring)
Some thing is wrong in here
var data = {
       "total": "1",
       "page": "1",
       "records": "2",
       "rows" : [
         {"id" :"1", "cell" :["cell11", "cell12", "cell13","cell13"]},
         {"id" :"2", "cell":["cell21", "cell22", "cell23","cell13"]},
       ]
      };
Researched and found that changing  datatype : "jsonstring", TO datatype : "json",  WORKED
I am pretty sure some bug has squeezed in some where...Â
with regards
Karthik
17:26
Moderators
30/10/2007
Hello,
Â
When jsonstring is set as datatype jqGrid expects the datastr parameter to be set as string.
addJsondata will not work in your case. Look in the docs for data manipulation.
Dynamically this can be achieved if you use setGridParam to set datastr and the reload the grid.
Â
Regards
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
Most Users Ever Online: 715
Currently Online:
42 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.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66