465
Views
4
Comments
Iterate the list in javascript

Hi,

I have Written my javascript in expression and set its escape content to NO, and I have one local variable say LatlongList which is returning the list of latlong fetching from database.

now, I want to iterate LatlongList into the javascript code which is written in expression.

how I can iterate the list please suggest me.


2020-08-26 14-54-58
Raghuram kamath

Convert your ousystem list to a outsystem string that resembles a Javascript list

Use String Concat within Expression to embed the list within the Javascript expression.

Use for loop in Javascript to loop over it.


Hope this helps

2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

1. Convert list to JSON string in OutSystems.

2. Pass string to JavaScript

3. Use JavaScript JOSN.parse() function to generate a JSON object from the string

4. Iterate the list elements in the JSON object

With jQuery

$.each(obj, function(key, value) {
    console.log(key, value);
});

Or with hstandard javascript

for (var prop in p) {
    if (!p.hasOwnProperty(prop)) {
        //The current property is not a direct property of p
        continue;
    }
    //Do your logic with the property here
}
UserImage.jpg
Gautam sharma

Daniël Kuhlmann wrote:

1. Convert list to JSON string in OutSystems.

2. Pass string to JavaScript

3. Use JavaScript JOSN.parse() function to generate a JSON object from the string

4. Iterate the list elements in the JSON object

With jQuery

$.each(obj, function(key, value) {
    console.log(key, value);
});

Or with hstandard javascript

for (var prop in p) {
    if (!p.hasOwnProperty(prop)) {
        //The current property is not a direct property of p
        continue;
    }
    //Do your logic with the property here
}

Thank you so much its working for me.


2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

Hi Gautam,

You're welcome.

Have a nice day :)

Regards,

Daniel

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.