Page 2 of 7
How to map a distinct array of results from a column (field) to a list?
Posted: Fri Jul 26, 2013 10:22 am
by Shaun Summers
Hi,
Thanks. Attached is a screen shot. I don't really know what I'm doing...
I've created an event on the data side and included some javascript. I'm not sure how to reference the data and I'm sure there are other errors...
I then have the fill_brand_dropdown run as an event on the Design side:
Thanks for your time.
How to map a distinct array of results from a column (field) to a list?
Posted: Fri Jul 26, 2013 10:26 am
by Shaun Summers
Sorry. Just realised that I attached the javascript event to the wrong component in the first screen shot. I've now attached it to fill_brand_dropdown but I still can't get it to work.
How to map a distinct array of results from a column (field) to a list?
Posted: Fri Jul 26, 2013 11:13 am
by Kateryna Grynko
Hi Shaun,
To get server data on Success event add Run JavaScript action where access the first item of "arguments" pseudo-array: arguments[0].
How to map a distinct array of results from a column (field) to a list?
Posted: Fri Jul 26, 2013 11:27 am
by Shaun Summers
I'm sorry Katya but I don't understand what you are telling me. I have the "on Success, run Javascript" in place. What does this mean: "where access the first item of "arguments" pseudo-array: arguments[0]."
If you have time then code you give me an example.
Thanks.
How to map a distinct array of results from a column (field) to a list?
Posted: Fri Jul 26, 2013 12:37 pm
by Kateryna Grynko
Hi Shaun,
All Appery.io event handlers do not have parameters transmissions described in the code. But the parameters are always passed anyway. They just do not have a name. The built-in JS pseudo-array "arguments" that is always accessible within functions is used to access them. This object contains the passed parameters as array elements.
In the case of action on Success event, the data comes in the first argument of the function, and therefore are available in arguments [0].
That is, to get the response data you would need the following JavaScript code:
codevar data = arguments[0];
// here you can try check it by uncomment next line
// alert( JSON.stringify( data ) );/code
How to map a distinct array of results from a column (field) to a list?
Posted: Fri Jul 26, 2013 5:55 pm
by Shaun Summers
Much clearer. Thanks. I'll give it a go.
How to map a distinct array of results from a column (field) to a list?
Posted: Mon Jul 29, 2013 4:04 pm
by Shaun Summers
Hi,
I'm sorry to come back again. I can get the values using the code that you gave me and it works when I try the alert. But when I try and populate the dropdown list I get nothing. This is the javascript I'm using:
code
var data = arguments[0];
var dropDown = $('select_brand');
$.each(data, function(index, option) {
mySelect.append(
$('<option></option>').index(index).option(option)
);
});
/code
Please tell me where I'm going wrong.
Thanks
How to map a distinct array of results from a column (field) to a list?
Posted: Mon Jul 29, 2013 8:11 pm
by Shaun Summers
Hi,
I found an error but still can't get it working. Most frustrating. I'll be happy when you've resolved the original bug that forced me into this workaround.
code
var data = arguments[0];
var dropDown = $([name=select_brand]);
$.each(data, function(index, option) {
dropDown.append(
$('<option></option>').index(index).option(option)
);
});
/code
How to map a distinct array of results from a column (field) to a list?
Posted: Mon Jul 29, 2013 8:14 pm
by Kateryna Grynko
Hi Shaun,
Your code is incorrect and won't work. Please use mapping to fill list.
How to map a distinct array of results from a column (field) to a list?
Posted: Mon Jul 29, 2013 8:24 pm
by Shaun Summers
How do I do that? I've got nothing to map. That was the original problem.
Sorry if I'm missing the obvious.