Page 1 of 7

How to map a distinct array of results from a column (field) to a list?

Posted: Thu Jul 25, 2013 3:49 pm
by Shaun Summers

I've created a service to get a list of distinct values for a column in the database:

{database_url}/collections/Sizes/distinct/Brand
(using the POST method);

When I test the service I get the correct result:

[
"Gap",
"Gant",
"Celio",
"Gant Test"
]

I then create my service response, which just outputs an array ($) - the column name 'Brand' is not included in the results and hence is not created in the service response.

I'm then stuck when it comes to mapping the result to a drop down list. I can map the array to the mobileselectmenuitem but I don't have a field available (Brand) to map to the Label.

Please point me in the right direction. Thanks.


How to map a distinct array of results from a column (field) to a list?

Posted: Thu Jul 25, 2013 5:56 pm
by Maryna Brodina

Hello! Looks like a bug, we'll research it more. For now as a workaround on service Success using JS create drop down list (this should help http://docs.appery.io/tutorials/build...)


How to map a distinct array of results from a column (field) to a list?

Posted: Thu Jul 25, 2013 8:44 pm
by Shaun Summers

Thanks but that won't really help. I don't know the values that will be in the list. They are created by the users of the app.

Any other suggestions?


How to map a distinct array of results from a column (field) to a list?

Posted: Thu Jul 25, 2013 9:14 pm
by Maryna Brodina

You don't need to know values. All values returned from server will be in variable "data" in service success function. In variable will be array with values. You can use this variable to form drop down list as shown in example http://docs.appery.io/tutorials/build....


How to map a distinct array of results from a column (field) to a list?

Posted: Thu Jul 25, 2013 9:28 pm
by Shaun Summers

OK. I get the idea. Thanks.


How to map a distinct array of results from a column (field) to a list?

Posted: Thu Jul 25, 2013 9:42 pm
by maxkatz

Could you also post a screen shot of the database, and its structure?


How to map a distinct array of results from a column (field) to a list?

Posted: Thu Jul 25, 2013 9:51 pm
by Shaun Summers

Here is a screen shot. There are 4 collections and the collection that I'm referencing has 7 fields +ID. All 7 fields are strings.

Hope this helps. Image


How to map a distinct array of results from a column (field) to a list?

Posted: Thu Jul 25, 2013 10:32 pm
by maxkatz

Thanks..we are going to check why it's happening and fix it.


How to map a distinct array of results from a column (field) to a list?

Posted: Fri Jul 26, 2013 9:20 am
by Shaun Summers

Hello,

I've been trying the javascript approach but I can't get it to work. Mainly because I can't seem to work out how the reference the data for the array.

I was wondering whether I could try something else as a workaround. What I had in mind was to use the standard list service to pull the full list of fields so that I had my field available to map. Then to use a 'where' javascript to restrict the output to records containing distinct values for the field 'Brand.' What do you think?

Is there a piece of javascript for "where [field name values] = distinct value" ?

Thanks, Shaun


How to map a distinct array of results from a column (field) to a list?

Posted: Fri Jul 26, 2013 9:41 am
by Kateryna Grynko

Hi Shaun,

Could you please show us the code you tried?
What exactly you did and what's not working?