[SailfishDevel] Hidden information to ListView

christopher.lamb at thurweb.ch christopher.lamb at thurweb.ch
Sat Feb 22 19:51:20 UTC 2014


Jukka

It is very easy to add multiple roles / fields with the same append command.

Here is an example culled from one of my apps:


var db = DB.DataModel();
var rs = db.getContacts(area_id, template_id);
for(var i = 0; i < rs.rows.length; i++) {
    contactModel.append({"name": rs.rows.item(i).name, "phone":  
rs.rows.item(i).phone, "primary_contact":   
rs.rows.item(i).primary_contact, "contact_id":  rs.rows.item(i).id});
}

HTH

Chris


Zitat von "Jukka Heikkilä" <jutsco at gmail.com>:

> I'm creating page which shows some information which is returned from
> local storage. I have successfully created the next code which will
> work:
>
> Page {
>     root
>
>     Component.onCompleted: {
>         //External Function which return the items from Local Storage
>         items = DB.listItems();
>
>         //Adding items to list view
>         for(var i = 0; i < items.rows.length; i++){
>                 listItems.model.append({"itemValue":
> items.rows.item(i).itemValue})
>         }
>     }
>
>
>     SilicaListView {
>         id: listItems
>         model: listModel
>
>         VerticalScrollDecorator {}
>
>         delegate: ListItem {
>             id: contentListItem
>
>             Label {
>                 text: itemValue
>             }
>         }
>     }
>
>     ListModel {
>         id: listModel
>     }
> }
>
> I would like to include some hidden values (e.g. DB row ID) for later
> usage, but is there possibilities to include extra data with same
> append command to the ListItem? I know the properties, but I haven't
> managed how to pass the variables in it.
>
>
> I would be grateful for your help.
>
> Kind Regards,
> Jukka
> @Juukks
> _______________________________________________
> SailfishOS.org Devel mailing list
>





More information about the Devel mailing list