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
Issue in getting the grid to work...
18/12/2009
21:07
Avatar
David
Guest
Guests

I posted this on the blog before I noticed you had a forum as well, so I do apologise for crossposting on two locations!!!  You can remove the blog comment if you wish, and I have bookmarked this forum now...

That being said, here is a copy of my post...

---

Hi,

First of all – wow and thank you for a great library! It’s looking fantastic, and I am currently migrating an old grid we used to use your library.

For some reason though, I’m not getting it to work, and I hope you might take a look at the following.

My JS is as follows:

jQuery(”#grdListAllLedgerAccount0_jqdg”).jqGrid(
{
url:’jsonserver.php?JQDG=1&_rw=3&_l=en&_c=LedgerAccount&_a=adminManage&_s=0&&AJAXGRID=grdListAllLedgerAccount0′,
datatype: “json”,
autowidth: true,
height: “auto”,
colNames:[
'Inv No',
'Date',
'Client',
'Amount',
'Tax',
'Total',
'Notes'],
colModel:[
{name:'id',index:'id', width:60, sorttype:"int"},
{name:'invdate',index:'invdate', width:90, sorttype:"date"},
{name:'name',index:'name', width:100},
{name:'amount',index:'amount', width:80, align:"right",sorttype:"float"},
{name:'tax',index:'tax', width:80, align:"right",sorttype:"float"},
{name:'total',index:'total', width:80,align:"right",sorttype:"float"},
{name:'note',index:'note', width:150, sortable:false} ],
multiselect: true,
caption: ” Ledger Accounts”,
rowNum:10
}
);

The PHP script – I believe correctly – returns the following JSON:

{”page”:1,”total”:2,”records”:13,”rows”:[{"id":1,"invdate":"2007-10-1","name":"Test name 1","note":"Test note 1","amount":1,"tax":0.21,"total":1.21},{"id":2,"invdate":"2007-10-2","name":"Test name 2","note":"Test note 2","amount":4,"tax":0.84,"total":4.84},{"id":3,"invdate":"2007-10-3","name":"Test name 3","note":"Test note 3","amount":9,"tax":1.89,"total":10.89},{"id":4,"invdate":"2007-10-4","name":"Test name 4","note":"Test note 4","amount":16,"tax":3.36,"total":19.36},{"id":5,"invdate":"2007-10-5","name":"Test name 5","note":"Test note 5","amount":25,"tax":5.25,"total":30.25},{"id":6,"invdate":"2007-10-6","name":"Test name 6","note":"Test note 6","amount":36,"tax":7.56,"total":43.56},{"id":7,"invdate":"2007-10-7","name":"Test name 7","note":"Test note 7","amount":49,"tax":10.29,"total":59.29},{"id":8,"invdate":"2007-10-8","name":"Test name 8","note":"Test note 8","amount":64,"tax":13.44,"total":77.44},{"id":9,"invdate":"2007-10-9","name":"Test name 9","note":"Test note 9","amount":81,"tax":17.01,"total":98.01},{"id":10,"invdate":"2007-10-10","name":"Test name 10","note":"Test note 10","amount":100,"tax":21,"total":121},{"id":11,"invdate":"2007-10-11","name":"Test name 11","note":"Test note 11","amount":121,"tax":25.41,"total":146.41},{"id":12,"invdate":"2007-10-12","name":"Test name 12","note":"Test note 12","amount":144,"tax":30.24,"total":174.24},{"id":13,"invdate":"2007-10-13","name":"Test name 13","note":"Test note 13","amount":169,"tax":35.49,"total":204.49}]}

When the above code is ran, however, javascript is returning the following error in my firebug:

cur is undefined

anonymous(Object page=1 total=2 records=13 rows=[13], div.ui-jqgrid-bdiv, Object name=rcnt value=0, Object name=more value=false, Object name=adjust value=0)jquery.j…id.min.js (regel 10)
anonymous(XMLHttpRequest readyState=4 status=200 statusText=OK, “success”)jquery.j…id.min.js (regel 10)
L()jquery.min.js (regel 19)
anonymous(8)jquery.min.js (regel 19)
[Break on this error] (function($){$.jgrid=$.jgrid||{};$.exten…$t.p.id).resizable(opts)})}})})(jQuery);

Am I overlooking something here?

Thanks for a quick look at this!!! And once again – WOW and THANKS! 

18/12/2009
21:34
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

Thanks. everthing will work also if you configure the jsonReader.

More you can find here.

http://www.trirand.com/jqgridw.....#json_data

Maybe you will need only to set in the reader - repeatitems:false and your grid will work.

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

18/12/2009
21:58
Avatar
David
Guest
Guests

Thanks for the fantastically fast response!!!  This is MUCH appreciated.

For some reason I did not find that info before.

I fixed it, but I don't see what is wrong now...

The page is now loading its 10 records, but unfortunately I'm still not seeing data IN the grid...

Any idea what might be causing this?

18/12/2009
22:30
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

Try

jsonReader:{repeatitems:false, id:"0"}

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.

18/12/2009
22:35
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

And again me,

or set in colModel key:true property

i.e

$("#mygrid").jqGrid({

..

colModel:[

{name:'id',index:'id', width:60, sorttype:"int", key:true}

..

],

jsonReader: {repeatitems:false},

...

});

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.

18/12/2009
22:45
Avatar
David
Guest
Guests

Hi Tony,

I tried it, but it doesn't seem to be working either.

I do in fact repeat the item names in my data returned from PHP, but I think I'm positioning something in the wrong location of the array...

This is the latest version of the javascript code I tried:

jQuery("#grdListAllLedgerAccount0_jqdg").jqGrid(

  {
  url:'jsonserver.php?JQDG=1&_rw=3&_l=en&_c=LedgerAccount&_a=adminManage&_s=0&&AJAXGRID=grdListAllLedgerAccount0',
  datatype: "json",
  autowidth: true,
  height: "auto",
  colNames:[
 ' Inv No',
 'Date',
 'Client',
 'Amount',
 'Tax',
 'Total',
 'Notes'],
 colModel:[
 {name:'id',index:'id', width:60, sorttype:"int"},
 {name:'invdate',index:'invdate', width:90, sorttype:"date"},
 {name:'name',index:'name', width:100},
 {name:'amount',index:'amount', width:80, align:"right",sorttype:"float"},
 {name:'tax',index:'tax', width:80, align:"right",sorttype:"float"},
 {name:'total',index:'total', width:80,align:"right",sorttype:"float"},
 {name:'note',index:'note', width:150, sortable:false} ],
 multiselect: true,
 caption: "<img src='/images/icons/16x16/plain-v/folder2_blue.png'> Ledger Accounts",
 rowNum:10,
 jsonReader : {
 root: "data",
 page: "page",
 total: "total",
 records: "records",
 repeatitems: true,
 cell: "rec",
 id: "id",
 userdata: "userdata"
 }
}
);
The data is sent back from PHP as follows:
{"page":1,"total":1,"records":10,"data":[{"id":1,"rec":{"id":1,"invdate":"2007-10-1","name":"Test name 1","note":"Test note 1","amount":1,"tax":0,"total":0}},{"id":2,"rec":{"id":2,"invdate":"2007-10-2","name":"Test name 2","note":"Test note 2","amount":4,"tax":0,"total":0}},{"id":3,"rec":{"id":3,"invdate":"2007-10-3","name":"Test name 3","note":"Test note 3","amount":9,"tax":0,"total":0}},{"id":4,"rec":{"id":4,"invdate":"2007-10-4","name":"Test name 4","note":"Test note 4","amount":16,"tax":0,"total":0}},{"id":5,"rec":{"id":5,"invdate":"2007-10-5","name":"Test name 5","note":"Test note 5","amount":25,"tax":0,"total":0}},{"id":6,"rec":{"id":6,"invdate":"2007-10-6","name":"Test name 6","note":"Test note 6","amount":36,"tax":0,"total":0}},{"id":7,"rec":{"id":7,"invdate":"2007-10-7","name":"Test name 7","note":"Test note 7","amount":49,"tax":0,"total":0}},{"id":8,"rec":{"id":8,"invdate":"2007-10-8","name":"Test name 8","note":"Test note 8","amount":64,"tax":0,"total":0}},{"id":9,"rec":{"id":9,"invdate":"2007-10-9","name":"Test name 9","note":"Test note 9","amount":81,"tax":0,"total":0}},{"id":10,"rec":{"id":10,"invdate":"2007-10-10","name":"Test name 10","note":"Test note 10","amount":100,"tax":0,"total":0}}]}
If I'm reading docs okay, I told the grid to get data from "data" branch in the array by setting "root" to "data.
Then within data, I have the data records structured as follows:
id: XXX
rec:
    |--> id: XXX
    |--> invdate: XXX
    |--> ... all other data fields
Is that correct?  I set cell to "rec" and id to "id" in javascript  and made sure each rec has the same column ids as initially initialised by javascript...
22/12/2009
09:18
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

I think you make the same error.

In you case with this configuration you should set in jsonReader - repeatitems:false.

Best 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:
55 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