Forum


10:59

01/09/2008

I have some Javascript code that iterates through an array of selected records and, in order to pass the selected record data to my servlet as a parameter I need to parse the selected data into a string. However, when I access the row data the data comes back as "undefined". The code is nearly identical to some code I saw in an example. I don't know what I am doing wrong. The relevant code is:
var selRow;
var selRecords = new Array();
var passedArray = new Array();
var i,j;
selRecords = $("#abslist").getGridParam('selarrrow');
i = selRecords.length;
if(i>0)
{
for(j=0;j<=i;j++){
selRow = $("#absList").getRowData(selRecords[j]);
passedArray[j] = selRow.absId + "," + selRow.absDate;
}
The selRecords variable has an array of selected record ID's. The selRow variable has a type "object" which, in debug, has no properties.
The passedArray variable ends up having the the value [undefined,undefined,undefined,undefined]
Relevant portion of the colModel:
colModel:[
{name:'absId',index:'absId', width:80},
{name:'absDate',index:'absDate', width:90}
]
What should I look for? Both Firebug and the Venkman debugger display "No properties" when I examine the value of the row data object in debug mode.
Thanks
04:29

Moderators
30/10/2007

Hello,
I think that the problem is here:
var selRecords = new Array();
You should not define the array. jqGrid return empty array if there are
no selected rows. You simple should check the values of this array.
What you have here? Are there any valid values from the selected rows?
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.
09:58

01/09/2008

Thanks Tony. I originally had the array defined as just var but specifically cast it to an Array hoping to fix the problem (which it didn't).
Yes. The selRecords array does have the correct values for the selected records. There are 4 records displayed and I selected record 2 and 3. The selRecords array has [2],[3] as values.
I took some screen shots of the Firebug and Venkman debugger showing the values and the 'void' value of selRow object. You can find the three screen shots here:
http://www.petesworkshop.com/images/jqgrid-1.jpg
http://www.petesworkshop.com/images/jqgrid-2.jpg
http://www.petesworkshop.com/images/jqgrid-3.jpg
I am not sure why jqgrid is returning an object that is void (undefined) I don't know much about Javascript but it almost seems like it doesn't know what the object is that is being returned by getRowData.
I hope this helps. I am stumped.
17:52

01/09/2008

tony said:
Hello,
I think that the problem is here:
var selRecords = new Array();
You should not define the array. jqGrid return empty array if there are
no selected rows. You simple should check the values of this array.
What you have here? Are there any valid values from the selected rows?
Regards
Tony
18:23

01/09/2008

tony said:
Hello,
I think that the problem is here:
var selRecords = new Array();
You should not define the array. jqGrid return empty array if there are
no selected rows. You simple should check the values of this array.
What you have here? Are there any valid values from the selected rows?
Regards
Tony
18:50

01/09/2008

Sorry about the multiple posts. I can't seem to add another reply to the thread!
I have a page that displays the json data and the colModel. It might help you figure out the problem:
01:58

Moderators
30/10/2007

Hello,
If poosible could you please prepare a test page for this. If you can do this
please include the development version of jqGrid.
Kind 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.
13:00

01/09/2008

Tony,
I am not sure what you mean by "development" version of jqGrid but I did create a demo servlet that should allow you to test this. Actually, you could rewrite the url to pull the same json data from a php method and run this in PHP if you wanted to. The json data is posted here along with my colModel:
http://www.petesworkshop.com/j.....oblem.html
All I did to prepare this test was to take the json data and return it as a string n the url "call" to the server.
The link to th test site is here:
Click on "start" and then a page with "List Absences" and "Display Selected Rows" buttons will display. Click on "List Absences" and it will populate the grid. Select a couple of rows and it will display the row number and then it *should* display the returned row information but it only displays "undefined" for each element in the row object.
I hope this will help.
06:59

Moderators
30/10/2007

Hello there is a typo error here:
You write:
selRow = $('#absList').getRowData(selRecords[j]);
IMHO it should be
selRow = $('#abslist').getRowData(selRecords[j]);
Correcting this work as expected.
Regrds
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.
Most Users Ever Online: 715
Currently Online:
74 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.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66