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
Problem using repeatItems: false with jsonReader
03/04/2009
15:14
Avatar
jukea
Member
Members
Forum Posts: 3
Member Since:
03/04/2009
sp_UserOfflineSmall Offline

Hi,

I'm trying to pass from a working grid configuration using jsonReader -> repeatItems:true (the value by default), to a version with repeatItems: false , that is having the cells described as key:value pairs instead of simply values in the json data.

Example ..: This works :

json data :

{"page":1,"total":1,"records":7,"rows":[{"id":"1","cell":["1","1joe","c6lark","12390 293 12 30 12"]}
,{"id":"2","cell":["2","2joe","5clark","12390 293 12 30 12"]},{"id":"3","cell":["3","3joe","5clark","12390
 2545493 12 30 12"]},{"id":"4","cell":["4","5joe","4clark","12390 293 12 30 12"]},{"id":"5","cell":["5"
,"6joe","3clark","12390 293 12 30 12"]},{"id":"6","cell":["6","7joe","12clark","12390 293 12 30 12"]
},{"id":"7","cell":["7","8joe","1clark","12390 293 12 30 12"]}]}

client code :

     $("#grid_349367564").jqGrid(
      {
        colNames:['Id','Firstname','Lastname','Tel'],
        colModel:[
          {width:40, resizable:false, name:"id", index:"id"},
          {width:"100", resizable:false, name:"firstname", index:"firstname"},
          {width:"100", resizable:false, name:"lastname", index:"lastname"},
          {width:140, resizable:false, name:"tel", index:"tel"}
        ],
        datatype:"json",
        imgpath:"\\/espLibGridPlugin\\/themes\\/steel\\/images",
        height:"auto",
        viewrecords:true,
        loadError:"function(xhr,st,err) {alert(\\"Type: \\"+st+\\"; Response: \\"+ xhr.status + \\" \\"+xhr.statusText);}",
        url:"\\/gridData?md=dummy&nd=1238788660",
        id:"grid_349367564",
        pager:"grid_pager_1138251041"    });

However, after using the fieldname as row data keys

json data :

{"page":1,"total":1,"records":7,"rows":[{"id":"1","cell":{"id":"1","firstname":"1joe","lastname":"c6lark"
,"tel":"12390 293 12 30 12"}},{"id":"2","cell":{"id":"2","firstname":"2joe","lastname":"5clark","tel"
:"12390 293 12 30 12"}},{"id":"3","cell":{"id":"3","firstname":"3joe","lastname":"5clark","tel":"12390
 2545493 12 30 12"}},{"id":"4","cell":{"id":"4","firstname":"5joe","lastname":"4clark","tel":"12390 293
 12 30 12"}},{"id":"5","cell":{"id":"5","firstname":"6joe","lastname":"3clark","tel":"12390 293 12 30
 12"}},{"id":"6","cell":{"id":"6","firstname":"7joe","lastname":"12clark","tel":"12390 293 12 30 12"
}},{"id":"7","cell":{"id":"7","firstname":"8joe","lastname":"1clark","tel":"12390 293 12 30 12"}}]}

client code : (only the jsonReader directive is added)

      $("#grid_2020711008").jqGrid(
      {
        colNames:['Id','Firstname','Lastname','Tel'],
        colModel:[
          {width:40, resizable:false, name:"id", index:"id"},
          {width:100, resizable:false, name:"firstname", index:"firstname"},
          {width:100, resizable:false, name:"lastname", index:"lastname"},
          {width:140, resizable:false, name:"tel", index:"tel"}
        ],
      datatype:"json",
        imgpath:"\\/espLibGridPlugin\\/themes\\/steel\\/images",
        height:"auto",
        viewrecords:true,
        loadError:"function(xhr,st,err) {alert(\\"Type: \\"+st+\\"; Response: \\"+ xhr.status + \\" \\"+xhr.statusText);}",
        url:"\\/gridData?md=dummy&nd=1238788604",
        jsonReader:["repeatItems",false],
        id:"grid_2020711008",
        pager:"grid_pager_43731544"    });

I correctly get the number of rows in the pager, but no row is shown. Ca you see what I'm doing wrong ?

On a side note, is it possible to get an error from this ? even using loadError as above, I never get an alert box. I suppose that is because the server answers with a 200 response, even if the json data is not correct. But is it possible to detect json data malformation with an event / error ?
 
Thanks for your great work!

03/04/2009
15:31
Avatar
jukea
Member
Members
Forum Posts: 3
Member Since:
03/04/2009
sp_UserOfflineSmall Offline

oops, i discovered a bug, I changed

jsonReader:["repeatItems",false],

to

jsonReader:{"repeatItems":false},

but it still doesn't work...

by the way, the reason you see all those escaped slashes ( \\/ ),
is that I'm making a php wrapper to generate the javascript, and I json_encode the values.
It works well (ie: the paths are parsed correctly).
06/04/2009
09:55
Avatar
jukea
Member
Members
Forum Posts: 3
Member Since:
03/04/2009
sp_UserOfflineSmall Offline

Just to clarify, I still have the problem even with the fix I did. The formatting of the last post might be confusing..

07/04/2009
08:06
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

I think that in this case you should outut the data this way:

{”page”:1,”total”:1,”records”:7,”rows”:[ {"id":"1","firstname":"1joe","lastname":"c6lark"
,"tel":"12390 293 12 30 12"},...

If this is not possible use jsonmap property like this

jsonmap : 'cell.firstname'

Regards

Tony

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:
46 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