Reputation: 61
I am trying to access userdata I have sent from the server (using coldfusion) to filter the display of edit or add icons depending on users's role. Example of userdata value is "all" or "add" or "edit" or "view".
From firebug an example of userdata looks like
,"USERDATA":"all"
The jsonreader looks like this
jsonReader: {
root: "ROWS", //our data
page: "PAGE", //current page
total: "TOTAL", //total pages
records:"RECORDS", //total records
userdata: "USERDATA",
cell: "", //Not Used
ar_bill_key: "0",//Will default to first column
id:"10"
},
I am trying to find the userdata so I can figure out how to use it. The code below returns undefined in firebug. I'm new to this so it's not set up correctly. Any advice would be appreciated. I have looked at and tried many examples but it's not working yet
loadComplete:jQuery("#List").getGridParam("userdata")
alert("userdata")
Thanks
Upvotes: 1
Views: 1234
Reputation: 221997
You have some errors. The first one is: the name of parameter is 'userData'
and not 'userdata'
. So to get the value send from the server you should use
var myData = $("#List").jqGrid('getGridParam', "userData");
The next error: the loadComplete
is a callback function so the code
loadComplete:jQuery("#List").getGridParam("userdata")
is wrong.
The last error is: the value of userdata
which will be sent from the server have to be object. So you should place something like
"USERDATA":{"status":"all"}
instead or
"USERDATA":{"status":"all"}
If you use
jsonReader: {
...
userdata: "USERDATA",
...
}
then you can display the value from loadComplete
like the following:
loadComplete: function () {
var myData = $(this).jqGrid('getGridParam', "userData");
alert(myData.status);
}
Upvotes: 1