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_Related Related Topics sp_TopicIcon
jqgrid using datatype:"local" to read a json string with customised localreader
26/10/2012
02:56
Avatar
casbby
Member
Members
Forum Posts: 3
Member Since:
17/10/2012
sp_UserOfflineSmall Offline

Hi,

During my question about how to re-apply the toolbar filter after the underline data is refreshed from a local js var question asked here , Oleg has provided me an solution:
1 use the combination of datatype:"local" and data:localvar.

Now I am facing a different problem which after a week I was not able to solve.

According to the Jqgrid wiki when using local datasource the default localreader looks like

   

The initial configuration of the localReader is the same as those from jsonReader

    localReader = {
       root: "rows",
       page: "page",
       total: "total",
       records: "records",
       repeatitems: false,
       cell: "cell",
       id: "id",
       userdata: "userdata",
       subgrid: {root:"rows", repeatitems: true, cell:"cell"}
    }

I found this is not the case. Because in every examples that i can find using dataype:"local", it always uses a straight js array in stead of an js object, looking like this:

   

var mydata = [       
    {id:"1",invdate:"2007-10-01",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},   
       {id:"2",invdate:"2007-10-02",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
    {id:"3",invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"}];

I have tried using the default localReader (with

repeatitems set to true

) to process

   

var locObj = {"rows":[
           {"id":0,"cell":["val1","val2","val3"]},
           {"id":1,"cell":["val1","val2","val3"]}
            ],
      "page":"1",
      "total":"1",
      "records":"2"
    }

with
     datatype:"local",
     data:locObj

this will not work, because it wont pass the array check in the addlocaldata function. if I change the option to be
    

datatype:"local",
     data:locObj.rows

I got a grid with correct number of rows but each cell has an empty value. I think that is becasue the addlocaldata function can not handle an array formatted like locObj.rows.

"rows":[
           {"id":0,"cell":["val1","val2","val3"]},
           {"id":1,"cell":["val1","val2","val3"]}
            ]

is there a way to actually process a json object (or string) with the datatype:"local" using the customised localreader (in stead of having to re-create an array on the client side)?

Any help is greatly appreciated.

casbby

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
49 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