#1 2016-08-09 23:00:59

Bob
Member
Registered: 2016-08-09
Posts: 1

How to dynamically populate a DropDown control?

Hello David,

before I buy I have a few questions:

1. How to populate dynamically drop down select with data from database (city,zip,street)? is it possible and how? If you can, an example or .AB

2. whether it is possible to send custom push notification to certain users such as by user name ? If you can, an example or .AB

3. is it possible to get phone number from the user? (android) If you can, an example or .AB

would be grateful if you answer me

Thank you

Offline

#2 2016-08-10 00:16:00

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,657
Website

Re: How to dynamically populate a DropDown control?

Hello Bob,

Thanks for your interest in my work. Please, next time open a new forum's thread for every question, then we can maintain it better to future searchs, ok?

About your questions:

A Dropdown control is feed by using their "Items" variable. This variable is an Array and App Builder provide several actions in order to work with Arrays. For example, the below code populate a Dropdown control, as you can see in the Dropdown application sample already included in App Builder:

ArrayPush "[MyDropDown.Items]" "My item"
ArrayPush "[MyDropDown.Items]" "My other item"

Then I am not sure where the problem can be if the Dropdown "items" are retrieved from a remote database. If fact, what we must to do is an HTTP call (with the HttpClient control) in order to retrieve the "items", then the server can provide us a response in a more or less appropiate way.

Maybe you want to take a look at the "ParseVariables" action. This action can parse some string (who can be received from a server) like the below one:

MyItems=|My Item|My other item

If your server provide a response like that, then you only need to use the ParseVariables action with that response string, and after that you can directly assign the "MyItems" variable into the "Items" variable of your Dropdown control.

In fact there is not only one way to achieve that. The only thing we must to consider is the "Items" variable of a DropDown control is an Array, then we can feed such Array with local or remote data, with the appropiate "items".

Yes; it's possible, but requires some understanding and work. If you take a look at the "PushPlugin" sample, you know the applications must register itself to then receive push notifications. The "PushPlugin" act in a very easy way with this register process, in fact the PHP script called (it's included in the "PushPlugin" sample) just save the application ID in a text file.

Ok. Then the "sendpush.php" script just take such file and send a push notification to all the IDs found. Can you understand what I want to say Bob? Instead of save the register information in a simple text file, we can use a database, for example. In that case, when we want to send a push notification, instead to simply send it to all the registered IDs (apps) we can choose the IDs what we want to use.

So, yes, it's possible to send push notifications only to some of the users, but requires some work and understanding. For example, other thing we must to consider. What we receive from the applications when they register itself, maybe it's not useful for us in order to later select the users we want to send the notifications.

What this means? Well. Again, as you can see in the "PushPlugin" sample, we made an HTTP call to register the application. In the sample case we only send the app ID, but nothing disallow us to send other things to the server, for example, an user email address. Then we can ask the user for an email address, and, when we get it, call to the server in order to register the app.

Of course we can save the email at the same time, and then use it to decide who receive our push notifications.

The phone number is not something all the Android versions provide, or all the devices vendors provide, then there is not a suitable way to use it in order to get the user phone number. In my honest opinion, if you wanted the user phone number, you must ask for it to the user.

Hope this information can be useful for you Bob and thanks in advance for your support. If you have any further question, please, don't hesitate to place it here or open a new forum's thread if needed.

Offline

#3 2016-08-10 02:56:20

reg4app
Member
Registered: 2016-05-16
Posts: 147

Re: How to dynamically populate a DropDown control?

Hello Bob,
About your first question
I already try sails.js+waterline and Delphi MVC Framework to provide data,both can  populate dynamically Select control,
The Point is as long as your web service can provide JOSN data ,then You can get data and use it in AB


Joshua.Y

Offline

#4 2016-08-10 10:40:33

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,657
Website

Re: How to dynamically populate a DropDown control?

Hello,

Thanks Joshua. Thanks for your reply. Certainly JSON data is good, but, remember we can also receive a "simple" string to be used "as is", or with some further process like with the "ParseVariables" action. In this way we can also feed the Array of a Dropdown control. smile

Offline

#5 2016-08-11 00:36:02

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,657
Website

Re: How to dynamically populate a DropDown control?

Hello to all,

I want to put here an example about the "ParseVariables" action. Just look at the below code:

ParseVariables "MyDropDown.Items=|One|Two|Three"

Supose we receive the string "MyDropDown.Items=|One|Two|Three" from a server, ok? Then when the "ParseVariables" action is executed we already feed the DropDown control with "One", "Two" and "Three" items.

Offline

Board footer

Powered by FluxBB


Copyright ©2018 DecSoft. All rights reserved.