How to get info from next row in table

This forum contains topics that were moved from Get Satisfaction
Randy7611273
Posts: 0
Joined: Sat Jun 27, 2015 7:03 pm

How to get info from next row in table

Post by Randy7611273 »

Hello!

I have been trying desperately for a couple of weeks now to get information from the next row in a table. Here’s the layout:

Outer grid: “songsetgrid_out”, 1 row, 1 column
Inner grid: “songsetgrid_in”, 1 row, 4 columns

For testing purposes, column 2 of “songsetgrid_in” has one label, “songtitle.” The grid is populated from the database. Column 4 has a button, which runs Javascript. Using the following code, I can get info from the current row:

var table = jQuery(this).closest("table");
var row = table.find("tr").eq(0);
var songLabel = row.find('[name="songtitle"]');
var songTitle = songLabel.text();
console.log(songTitle);

However, trying to use the following code, I am unable to access the next, previous, or even current row:

var goalRow = x;
var table = jQuery(this).closest("table");
var row = table.find("tr:eq(" + (goalRow - 1) + ")");
var songLabel = row.find('[name="songtitle"]');
var songTitle = songLabel.text();
console.log(songTitle);

In fact, changing the eq value at all (ex: var row = table.find("tr").eq(1);) returns no results. I’ve also tried changing the value of closest("table") to closest("songsetgrid_out") and closest(“songsetgrid_in”), and I also get no results. Please help!

Thanks,
Randy

Serhii Kulibaba
Posts: 147
Joined: Tue Aug 27, 2013 1:47 pm

How to get info from next row in table

Post by Serhii Kulibaba »

Hello Randy,

You can get data from the chosen grid like shown here: https://devcenter.appery.io/documenta...

Randy7611273
Posts: 0
Joined: Sat Jun 27, 2015 7:03 pm

How to get info from next row in table

Post by Randy7611273 »

Apologies... When clicking the button on Row 1 (Item 1), I need to get information from Row 2 (Item 2): Next Row in Table.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

How to get info from next row in table

Post by Yurii Orishchuk »

Hi Randy,

You need to get iterated parent and get next or previous item.

You can try following JS code:

pre

var table = jQuery(this).closest("table").closest('[data-wrapper-for]');

//To get previous item.
var table = table.prev();

//To get next item.
//var table = table.next();

var row = table.find("tr").eq(0);
var songLabel = row.find('[name="songtitle"]');
var songTitle = songLabel.text();
console.log(songTitle);

/pre

Regards.

Randy7611273
Posts: 0
Joined: Sat Jun 27, 2015 7:03 pm

How to get info from next row in table

Post by Randy7611273 »

It's a beautiful thing! Thank you so much, Yurii!

Post Reply