Page 1 of 1

How to access values from other columns in a list item

Posted: Wed Apr 16, 2014 1:13 pm
by Bob Fludder

I have a list component, in it is a series of list items generated from a rest service. in the list item there is a grid, 3 columns. In the first column I have a code (in a label), second column has a description (also in a label). The 3rd column is a button. When I click on the button I go to a new page. I'd like to display the code & the description from the same line as the button to show on the heading of the new page. I'm sure I'd have to do this via a couple of local storage variables. The problem I'm having is getting the values into the local storage variables. I've tried something like Appery('code').text() but all I get is a blank field. I even tried a generic service but all I got there was a list of all the codes - not the one corresponding to the button clicked. Any other ideas ?


How to access values from other columns in a list item

Posted: Wed Apr 16, 2014 3:03 pm
by Maryna Brodina

Hello!

On button click add the following code prevar text = $($(this).parents()[2]).find("[name=code]").text();/prewhere "code" - label name


How to access values from other columns in a list item

Posted: Thu Apr 17, 2014 12:40 am
by Bob Fludder

Works brilliantly but one last question. I can see your constructing the name of the field so as to get the text but what does the "parents()[2])" mean ? I'm kind of new to javascript and just trying to understand/learn if that's ok.


How to access values from other columns in a list item

Posted: Thu Apr 17, 2014 4:39 am
by Igor

Hello Bob,

You could find description here: https://api.jquery.com/parents/#paren...


How to access values from other columns in a list item

Posted: Thu Apr 17, 2014 5:48 am
by Bob Fludder

Thanks for that (I think)