Loading an array from javascript results variable containing SQLite query


Ryan Sytsma

I have the below code to query a SQLite database when the app is offline.

The results JS variable is an array of records.

I want to take "window.App.RootScope.dailyCrews = results;" and set "dailyCrews" to the NewArray "arrDailyCrews".

Is that needed or can I just use "window.App.RootScope.dailyCrews" as my array on the AB code side?



DecSoft

Hello Ryan,

If I am understand well, what you asked is if the NewArray action is required. If so, in principle, it's not required, that is, you can create the Array variable just by assigning the "result" variable into "window.App.RootScope.dailyCrews", just like you do now.

However, certainly in some situations we need to declare a variable before can use it, for example, inside app functions. So maybe it's not a bad idea to use the "NewArray" action in the app Ready event, or the app view Show event.



Ryan Sytsma

Thank you David

If I do decide to use NewArray "arrDailyCrews" do I need to loop "window.App.RootScope.dailyCrews" to fill the new array or is it just a direct assignment?



DecSoft

Hello Ryan,

Talking about Javascript, you can directly assign the new array variable into the other without problems.


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.