jquery - Select all field values of an observable array in a comma separated string -


i've got observablearray this:

self.displaymessagecollection = ko.observablearray(); 

i'm getting collection , pushing items displaymessagecollection this:

self.displaymessagecollection.push({                                                     messageid: msgid,                         loader: 'block',                         uploadopacity: 'uploadopacity',                         sentstatus: 'wait',                         chattype: self.tochattype()                     }); 

i need messageid field values comma seperated string array.

i know can loop items , messageid values. want know if can query on observablearray, i.e. somehow single query field values comma seperated string?

you can use built in map function on underlying array , , can use join function comma separated string:

self.displaymessagecollection().map(function(i) { return i.messageid }).join(",") 

if need logic multiple times can create helper function observable array.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -