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
Retrieving Row Data
02/09/2008
10:59
Avatar
Pete
Member
Members
Forum Posts: 100
Member Since:
01/09/2008
sp_UserOfflineSmall Offline

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

03/09/2008
04:29
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

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.

03/09/2008
09:58
Avatar
Pete
Member
Members
Forum Posts: 100
Member Since:
01/09/2008
sp_UserOfflineSmall Offline

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.

03/09/2008
17:52
Avatar
Pete
Member
Members
Forum Posts: 100
Member Since:
01/09/2008
sp_UserOfflineSmall Offline

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


03/09/2008
18:23
Avatar
Pete
Member
Members
Forum Posts: 100
Member Since:
01/09/2008
sp_UserOfflineSmall Offline

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


03/09/2008
18:50
Avatar
Pete
Member
Members
Forum Posts: 100
Member Since:
01/09/2008
sp_UserOfflineSmall Offline

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:

http://www.petesworkshop.com/j.....oblem.html

04/09/2008
01:58
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

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.

04/09/2008
13:00
Avatar
Pete
Member
Members
Forum Posts: 100
Member Since:
01/09/2008
sp_UserOfflineSmall Offline

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:

http://web5250.com/asaap-v/IV

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.

05/09/2008
06:59
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

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.

05/09/2008
09:41
Avatar
Pete
Member
Members
Forum Posts: 100
Member Since:
01/09/2008
sp_UserOfflineSmall Offline

LOL!  Thanks!  I can't believe it was SO simple and I must have looked at that code a thousand times!  I had even cut and pasted that same code so eveb my tests and examples didn't work.

A second set of eyes is a good thing.  Thanks for taking the time!

This is a great tool! 

Pete

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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