[SailfishDevel] Hidden information to ListView

Jukka Heikkilä jutsco at gmail.com
Sun Feb 23 08:17:38 UTC 2014


Hi Chris and others,

yes I understand how to add more than one fields in the same append
command. The problem is that I would like to add hidden (not visible
for user) per ListItem. In my example which I send in my previous mail
was only one label which is visible for user, but how to add variables
inside the ListItem (row ID  of DB and other information) which I can
access from other functions like when deleting the item from screen
and db at the same time.

I tried to add inside ListItem this way:

delegate: ListItem {
   id: contentListItem
   property int itemId: itemId

   Label {
       text: itemValue
   }
}

and in the append({"itemValue": items.rows.item(i).itemValue,
"itemId", items.rows.item(i).itemId})

However, later when I'm calling:
contentItem.isDefault returns undefined.

I can't figure out what I'm doing wrong. I just want that I can delete
the item when I'm pressing the ListItem and getting the dropdown where
is selection Delete.

I hope that someone could help me with this.

Kind Regards,
Jukka

2014-02-22 21:51 GMT+02:00  <christopher.lamb at thurweb.ch>:
> 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