Can select control contain name:value pairs


Yang Ghua

i want to show a string in select control and when user select one item,will get another value to store to database,just like

select control list name string A and there are corresponding value to get like 1
B 2
C 3
D 4

therefore ,i can get both name string and the key value ,and save to the database...


decsoft

Hello Joshua,

I perfectly understand what you wanted, and, certainly, the HTML Select control allow us to put a "visible" value and a non visible one, that is, we can show to the user the string "A", but the Select's option (item) can have associated a value of "1", other number or other string.

Said that, App Builder doesn't work in the same way with the Select control, then we can't think in the above solution, but a possible workaround to get what we wanted. Remember we can deal with "normal" variables, "Array" variables and "Object" variables.

Maybe we can use some approach like if receive an object (maybe a JSON response) with pairs of keys and values, and then use the keys to feed the Select control. Then, when the Select changes we can iterate over the object variable to get the value of the key.

I think we can do that and maybe in others way too, so I want to ask you now, how you receive the key/values pairs? How you feed the Select control right now?



Yang Ghua

Thanks for the clue

Yes, data is array of JSON object

follow your suggestion,I work it through , see below :

a HttpClient1, set url to the JSON array url

in Success event


This is to fill the Select control

in a button's click event

this can work,but seems a lot of coding....
and by the way ,Is that a way to store the 'HttpClient1.Response' into variable??


decsoft

Hello Joshua,

Don't appear lot of code to me, and after all they have their sense and logic. The only think I see is something like this:

This can be work, but, I think not recommended. A better approach can be one of these:

About the "Response" of an HTTP Client control, if we are talking about a JSON response, then we can access that object directly using the "Response" variable, without any other thing to do before. You can take a look at some of the "JSON*" included app samples.

Please, Joshua, post here any further question you have.



Yang Ghua

Thanks ,I get it
just another question
when i test the sample ,even i just changed a label's Text,I had to delete the '_Compiled' folder to make the changes take effect...
and of course,i save the project before run.


Yang Ghua

OH,I find a way ,after change anything ,First 'Build' (F8),then run,and everything become OK
:)


decsoft

Hello Joshua,

Just for your information about the "Build", "Debug" and "Run" commands:

Build (F8) - This command build the application, but no save it before. This command is intented when want to deploy our application, that is, we debug it previously, save the latest changes and then we are ready to deploy so we use the "Build" command. The "Build" do not include debug information in the application, which is good to enter in production.

Run (CTRL + F9) - This command run the latest app's build available. They build the app (without save it first and without include debug information) if a previously build is not found. This command is intented to be use when we want to launch the latest build quick and fast, since this command don't save the app nor build it (if found an existing build) but just launch the latest build available.

Debug (F9) - This command save the application changes if any, then build the application including debug information on it, and finally launch the application into the integrated debugger. This command is intented to use when we are working on the application, and just want to debug it to review the latest changes, etc.

---

This last (Debug) is the prefered command when work in the application, since they include debug information in the application and additionally the Debug command doesnt' write manifests files for our applications nor other stuff which is not required to debug the application into the integrated debugger. So this is another point to use the "Build" (F8) command when we want to deploy our application: the "Build" command yes write manifests, prepare icons, splash screens, config files and other stuff.

So in conclusion:

1º Use the Debug (F9) command when work in the application. Additionally use the "Run" (CTRL+F9) when you only want to launch the latest build/debug.

2º Use the Build (F8) when you are ready with your application and want the files you need in order to deploy it into your desired platforms.

Hope this information can help you Joshua. :)



Yang Ghua

Your explaination is clear enough! smile
and I want to know if one view's content can be access from another view,like the "Response" of an HTTP Client control...,and so on


decsoft

Hello Joshua,

About this last question, I think you can access the "Response" variable. You must try it.

P.S. Please, put every new question in a new forum's thread. :)


Everybody can read the DecSoft support forum for learning purposes, however only DecSoft customers can post new threads. Purchase one or more licenses of some DecSoft products in order to give this and other benefits.

This website uses some useful cookies to store your preferences.

I agree. Hide this note. Give me more information.