Forum


16:59

25/01/2012

I have the following code
$(function(){
var x = "userData is: " + $("#t2").jqGrid.getGridParam('userData');
$("#t2").jqGrid({
url:'getData.php?urn=sqlite:////var/www/wiki/data/meta/money.db&table=jessica',
datatype: 'xml',
mtype: 'GET',
colNames:['id','Date', 'Description','Credit', 'Debit'],
colModel :[
{name:'id', index:'id', width:20, editable: true},
{name:'Date', index:'Date', width:50, editable: true},
{name:'Description', index:'Description', width:500, align:'right', editable: true},
{name:'Credit', index:'Credit', width:80, align:'right', editable: true},
{name:'Debit', index:'Debit', width:80, align:'right', editable: true}
],
pager: '#pager',
rowNum:10,
rowList:[10,20,30],
sortname: 'id',
sortorder: 'asc',
viewrecords: true,
gridview: true,
caption: x,
cellEdit: true,
userDataOnFooter: true,
footerrow: true
});
});
</script>
</head>
<body>
<H3><script>var msg="Hello everyone";document.write(msg);</script></H3>
<table id="t2"><tr><td/></tr></table>
<div id="pager"></div>
<table id="t3"><tr><td/></tr></table>
The userdata *is* being sent because I see it in the footer. However I can't see *any* other way to access it, I've tried $("#$("#t2").jqGrid.getGridParam('userData'); and $("#t2").getGridParam('userData'); both always return undefined. There seems no actual way to get at the userdata in a form that can actually be used.
While I'm about it the documentation refers to the 'options' array, is this an actual, accessible, array or is it just a way of describing things?
18:23

Moderators
30/10/2007

Well,
You refer to the documenation, but it seems you do not read it carefully.
Your calling convention is wrong.
Please refer here
http://www.trirand.com/jqgridw.....#user_data
Read to the end please
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.
19:54

25/01/2012

OK, I finally got there!
My code is now:-
$(function(){
$("#t2").jqGrid({
url:'getData.php?urn=sqlite:////var/www/wiki/data/meta/money.db&table=jessica',
datatype: 'xml',
mtype: 'GET',
colNames:['id','Date', 'Description','Credit', 'Debit'],
colModel :[
{name:'id', index:'id', width:20, editable: true},
{name:'Date', index:'Date', width:50, editable: true},
{name:'Description', index:'Description', width:500, align:'right', editable: true},
{name:'Credit', index:'Credit', width:80, align:'right', editable: true},
{name:'Debit', index:'Debit', width:80, align:'right', editable: true}
],
pager: '#pager',
rowNum:10,
rowList:[10,20,30],
sortname: 'id',
sortorder: 'asc',
viewrecords: true,
gridview: true,
caption: "Caption",
cellEdit: true,
userDataOnFooter: true,
footerrow: true,
loadComplete: function (x) {
var z = ""
var x = jQuery("#t2").jqGrid('getGridParam', 'userData')['Debit'];
alert(x);
}
});
});
... and I get to see my data in the alert box. I think my problem before was simply that I was trying to get at the userdata before the grid had been instantiated. The documentation doesn't help at all on this, I had the syntax of getGridParam correct but was calling it before there was any data to access.
I think there needs to be a full example using loadComplete (or something else) to show how to actually get some userdata by name and do something with it.
Most Users Ever Online: 715
Currently Online:
62 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