Re: [SailfishDevel] Hidden information to ListView

2014-02-23 Thread Jukka Heikkilä
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.l...@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ä jut...@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




___
SailfishOS.org Devel mailing list


Re: [SailfishDevel] Hidden information to ListView

2014-02-23 Thread Andrey Kozhevnikov

what the problem? You not forced to use all fields in any visual elements.

You can use model.get(index).fieldname for getting any field from model

On 23.02.2014 14:17, Jukka Heikkilä wrote:

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.l...@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ä jut...@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





___
SailfishOS.org Devel mailing list


___
SailfishOS.org Devel mailing list


Re: [SailfishDevel] Hidden information to ListView

2014-02-23 Thread Jukka Heikkilä
Hi,

that was the problem. Big thanks for your help.

Kind Regards,
Jukka

2014-02-23 10:21 GMT+02:00 Andrey Kozhevnikov coderusin...@gmail.com:
 what the problem? You not forced to use all fields in any visual elements.

 You can use model.get(index).fieldname for getting any field from model


 On 23.02.2014 14:17, Jukka Heikkilä wrote:

 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.l...@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ä jut...@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



 ___
 SailfishOS.org Devel mailing list


 ___
 SailfishOS.org Devel mailing list
___
SailfishOS.org Devel mailing list


[SailfishDevel] Hidden information to ListView

2014-02-22 Thread Jukka Heikkilä
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


Re: [SailfishDevel] Hidden information to ListView

2014-02-22 Thread christopher . lamb

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ä jut...@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





___
SailfishOS.org Devel mailing list