Page 3 of 7
How to map a distinct array of results from a column (field) to a list?
Posted: Tue Jul 30, 2013 6:30 am
by Maryna Brodina
Hello! Please try the following code:
codevar data = arguments[0];
var dropDown = Appery("mobileselectmenuName");
dropDown.empty();
$.each(data, function(index, option) {
dropDown.append(
$('<option value="' + option + '">' + option + '</option>')
);
});
dropDown.selectmenu("refresh");/code
How to map a distinct array of results from a column (field) to a list?
Posted: Tue Jul 30, 2013 8:10 am
by Shaun Summers
That works. Thank you very much. I really appreciate the help.
How to map a distinct array of results from a column (field) to a list?
Posted: Tue Jul 30, 2013 8:28 am
by Shaun Summers
For anybody picking up this thread. Here is the condensed version of what was done:
I initially create a new service (MySizeIn_Sizes_Distinct_List_Brands) to get the distinct values in a field from the appery database
I then added this service as a datasource to my page and named it “fill_brand_dropdown”
I noticed at this point that I had no field name available for mapping and opened this bug. Appery suggested the following as a work around:
I created the following Event on the data screen for my page:
fill_brand_dropdown Success Run JavaScript
I then entered the javascript posted above by appery. Just changing the mobileselectmenuName to the name of my dropdown list in the design screen.
This works. Thank you to Appery and I hope this helps somebody else.
How to map a distinct array of results from a column (field) to a list?
Posted: Tue Jul 30, 2013 1:17 pm
by Shaun Summers
Would anybody know how to add a placeholder into this code ie. 'Please select...' ?
The one for the component is getting overwritten by the javascript.
How to map a distinct array of results from a column (field) to a list?
Posted: Tue Jul 30, 2013 1:23 pm
by Maryna Brodina
Hi, not sure I understand what code you mean. Could you clarify please? If you want to post some code use < code tag.
How to map a distinct array of results from a column (field) to a list?
Posted: Tue Jul 30, 2013 1:31 pm
by Shaun Summers
Hi Marina,
The code that you kindly suggested:
code
var data = arguments[0];
var dropDown = Appery("mobileselectmenuName");
dropDown.empty();
$.each(data, function(index, option) {
dropDown.append(
$('<option value="' + option + '">' + option + '</option>')
);
});
dropDown.selectmenu("refresh");
/code
I'm just looking for a way to include a placeholder such as 'Please select...'.
Regards, Shaun
How to map a distinct array of results from a column (field) to a list?
Posted: Tue Jul 30, 2013 1:32 pm
by Maryna Brodina
How to map a distinct array of results from a column (field) to a list?
Posted: Tue Jul 30, 2013 1:47 pm
by Shaun Summers
How to map a distinct array of results from a column (field) to a list?
Posted: Tue Jul 30, 2013 1:53 pm
by Maryna Brodina
You would need to add an option with attribute data-placeholder="true"
codevar data = arguments[0];
var dropDown = Appery("mobileselectmenuName");
dropDown.empty();
dropDown.append($('<option data-placeholder="true">Choose one...</option>'));
$.each(data, function(index, option) {
dropDown.append(
$('<option value="' + option + '">' + option + '</option>')
);
});
dropDown.selectmenu("refresh");/code
How to map a distinct array of results from a column (field) to a list?
Posted: Tue Jul 30, 2013 1:59 pm
by Shaun Summers
Wonderful! Thanks a lot. I appreciate that this question was not directly related to your product and it was very kind of you to help.