Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
fredoust
Posts: 75
Registered: ‎09-12-2012
My Device: Looking for a BB10 testing device
Accepted Solution

GroupDataModel and append()

Hi all,

Why can't we do append() in a GroupDataModel ?

 

In some case it would be more usefull than insert()...

 

I have to do some tricky things to add an item at the end of my list

 

Thanks

---------
Mobile developer freelance - QtQuick - Cascades - WP7 - Android
My works : http://fdelgado.fr
Please use plain text.
Developer
kylefowler
Posts: 526
Registered: ‎05-17-2009
My Device: 9900

Re: GroupDataModel and append()

The purpose of groupdatamodel is to have headers and use sorting keys to order the items, its really not meant for linear lists. For that you should use ArrayDataModel
Like all of my posts
Please use plain text.
Developer
fredoust
Posts: 75
Registered: ‎09-12-2012
My Device: Looking for a BB10 testing device

Re: GroupDataModel and append()

Yes but in my case I have a linear list of qvariantmap and i want to access to ther properties like in GroupDataModel with ListItemData. Does ArrayDataModel allow it ? cause in my case it doesn't work with ArrayDataModel.

 

Thanks

---------
Mobile developer freelance - QtQuick - Cascades - WP7 - Android
My works : http://fdelgado.fr
Please use plain text.
Developer
kylefowler
Posts: 526
Registered: ‎05-17-2009
My Device: 9900

Re: GroupDataModel and append()

Yeah, all data models behave the same way when given to a list. No matter what kind of data model you use, ListItemData will always have the appropriate data for the index path. Of course, arraydatamodel does not take QObject* as an argument, so you will have to wrap the pointer in a qvariant, but then the QObject* will be what is represented by ListItemData
Like all of my posts
Please use plain text.
Developer
fredoust
Posts: 75
Registered: ‎09-12-2012
My Device: Looking for a BB10 testing device

Re: GroupDataModel and append()

I definitively not succed in using an ArrayDataModel, even with a C++ model, populate with qvariant.

The ListView doesn't use my custom ListItemComponent.

No probleme with GroupDataModel.

 

My ListView :

 

  ListView {                    
            dataModel: ModelPopulatedInCPP
            
             listItemComponents: [              
                             ListItemComponent {
                                 type: "item"
                                 Container {
                                     background: Color.Red
                                     Label {
                                         text: ListItemData.Label
                                     }
                                 }    
                             }         
   
                                ] 

        } 

  My model :

model = new ArrayDataModel();
QVariantMap map;
map.insert("Label", "Test");
model ->append(QVariant(map));

 

Thanks.

---------
Mobile developer freelance - QtQuick - Cascades - WP7 - Android
My works : http://fdelgado.fr
Please use plain text.
Developer
dridk
Posts: 91
Registered: ‎09-25-2012
My Device: bb10 alpha

Re: GroupDataModel and append()

// Drilldown navigation project template import bb.cascades 1.0 Page { Container { Button { text: "add" onClicked: { var data = {"nom":"schutz", "age":"23"}; model.append(data); } } ListView { dataModel: ArrayDataModel { id:model } listItemComponents: [ ListItemComponent { Button { text: ListItemData.nom } } ] } } }
a lover of Qt
Please use plain text.