PDA

View Full Version : Extract data from a LIST component from OUTSIDE THE LIST


ABC123

parkjammer
07-24-2013, 04:44 PM
When I use an action such as "onClick" within a LIST, I am able to retrieve
data from the list using constructs like this:




Result
Action


Works
var MyValue = this.selectionData[0].FIELD_XYZ;





However, if I am outside the LIST and attempting to pick up data using any
object (e.g., BUTTON "onClick" event) then I am unable to get a value.





MyPanel





MySimpleList


Row
FIELD_ABC
FIELD_XYZ


1
Red
Chair


2
Blue
Knob


3
Green
Lever






BUTTON











I've watched A5 videos, searched the forum, ensured my field-name capitalization is correct,
checked the in-developer samples and tips and still only manage to get errors or undefined values.

Here's what I've tried:




Result
Action


ERROR
var MyValue = {dialog.object}.getValue('list::MySimpleList::FIELD_XYZ');

Error: "Object doesn't support property or method 'getValue' "



Returns "undefined"
var MyValue = {dialog.object}.listGetValue('MySimpleList','FIELD_XYZ',0)


ERROR
var MyList_ID = {dialog.object}.getControl('MySimpleList');
var MyValue = MyList_ID.getValue(0).FIELD_XYZ;

Error: "Object doesn't support property or method 'getValue' "







I've tried a dozen variations on the theme. I've done exactly what has been done in the
videos.

To no avail thus far.

Any input, examples, or direction will be appreciated.

Selwyn Rabins
07-24-2013, 10:07 PM
perhaps this video will clear things up for you

http://screencast.com/t/MUCghmmxl

parkjammer
07-25-2013, 07:49 AM
Selwyn's video demonstrates a working "button gets LIST-data".

Having already tried several forms of the same thing, I was at least able to
determine that I'm not completely nuts and that I had been doing the right
things.

So... it had to be something else.

I separated the "populate LIST" and "get data" actions into two buttons
and... the same exact commands were able to work!

The answer was timing. The LIST was populating too late and the button's
request for data was too early.

So simply checking the box on the option "Run actions synchronously" fixed the problem.

Thanks for your help Selwyn.

Onwards!

kiwibruce
07-25-2013, 08:19 AM
Selwyn, good video, thanks

This would be a great video / example to add to the video list / documentation as I am sure Allan will not be the last person to need to do this.

B

gregincolumbus
07-25-2013, 09:14 AM
Good video..definitely helped me as well.....thanks Selwyn

Selwyn Rabins
07-25-2013, 11:01 AM
Selwyn's video demonstrates a working "button gets LIST-data".

Having already tried several forms of the same thing, I was at least able to
determine that I'm not completely nuts and that I had been doing the right
things.

So... it had to be something else.

I separated the "populate LIST" and "get data" actions into two buttons
and... the same exact commands were able to work!

The answer was timing. The LIST was populating too late and the button's
request for data was too early.

So simply checking the box on the option "Run actions synchronously" fixed the problem.

Thanks for your help Selwyn.

Onwards!

it is critically important for any developer of ajax applications (regardless of whether you are using alpha, php, asp.net, ruby, whatever) to understand the nature of ajax callbacks: they are asynchronous. that's the "A" in "AJAX". so you can't simply chain javascript commands together and expect then to operate in a nice sequential order.

one of the major additions to v12 was the addition of the 'run actions synchronously' checkbox to the action javascript editor to turn a set of synchronous actions into a set of synchronous actions.