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
JQGRID with JsonData using addJSONData ...need Help
06/10/2014
19:56
Avatar
nskarthik
New Member
Members
Forum Posts: 2
Member Since:
06/10/2014
sp_UserOfflineSmall Offline

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

13/10/2014
17:02
Avatar
nskarthik
New Member
Members
Forum Posts: 2
Member Since:
06/10/2014
sp_UserOfflineSmall Offline

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

21/10/2014
17:26
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

Forum Timezone: Europe/Sofia

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.com

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

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information