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
Contributor
SnGupta
Posts: 11
Registered: ‎01-24-2013
My Device: BB10

ListView row binding with ListView

Hi All,

 

I am curious to know about how to bind custom row with ListView and set row property(such as Level, ImageView,) dynamically with QML.?

 

Developer
Curahee
Posts: 229
Registered: ‎01-12-2013
My Device: z30

Re: ListView row binding with ListView

I'm not sure what you mean. Do you mean you want to customize your listitem? Here is an example of QML code where I use an ImageView and stuff to customize everything.

 

ListView {
    id: myList
    leftPadding: 10
    rightPadding: 10
    dataModel: GroupDataModel { }

    listItemComponents: [
        ListItemComponent {
            type: "item"
            
            Container {
                id: itemRoot
                layout: DockLayout { }
                
                Container {
                    topPadding: 20
                    bottomPadding: 20
                    leftPadding: 5
                    layout: StackLayout {
                        orientation: LayoutOrientation.LeftToRight
                    }
     
                    Container {
                        topPadding: 15
                        
                        ImageView {
                            imageSource: "asset:///images/myImage.png"
                        }
                    }
     
                    Container {
                        leftPadding: 15
                        layout: StackLayout { }
                        
                        Label { 
                            text: ListItemData.title
                            textStyle.fontSize: FontSize.Large
                            textStyle.lineHeight: 0.8
                            textStyle.color: Color.Black
                        }
                        
                        Label {
                            text: ListItemData.subtitle
                            textStyle.fontSize: FontSize.Small
                            textStyle.color: Color.Gray
                        }
                    }
                }
                
                Container {
                    layout: DockLayout {}
                    verticalAlignment: VerticalAlignment.Bottom
                    horizontalAlignment: HorizontalAlignment.Center
                    preferredHeight: 2
                    preferredWidth: 800
                    background: Color.Black   
                }
            }
        }
    ]
}

 If you meant something else, I'm happy to help if possible.

______________________________________________________
BB10-OAuth: GitHub
Developer
zezke
Posts: 1,004
Registered: ‎12-12-2010
My Device: Z10 (red Limited Edition)

Re: ListView row binding with ListView

[ Edited ]

I'm not sure if I get what you're after, but I think taking a look at the ListItemComponent might help you.

 

@Curahee Well played sir.

-------------------------------------------
BlackBerry Certified Builder for Native Application Development -- Proud member of the Belgian BlackBerry Developer group
Samples: Park in Ghent
Feeling generous? Nominate me for BB Elite member!
Contributor
SnGupta
Posts: 11
Registered: ‎01-24-2013
My Device: BB10

Re: ListView row binding with ListView

how can i set images, comming from server and lever also on a particualr position?
Contributor
SnGupta
Posts: 11
Registered: ‎01-24-2013
My Device: BB10

Re: ListView row binding with ListView

There is issue for handling server response, No issue for handling for local data
Contributor
SnGupta
Posts: 11
Registered: ‎01-24-2013
My Device: BB10

Re: ListView row binding with ListView

how can i find particular index id of ListView position

Label {
text: ListItemData.title
textStyle.fontSize: FontSize.Large
textStyle.lineHeight: 0.8
textStyle.color: Color.Black
}

how would i know which on is Title, which one is sub-title and which one is Status??
Developer
Curahee
Posts: 229
Registered: ‎01-12-2013
My Device: z30

Re: ListView row binding with ListView

I add an own written QObject to the the groupdatamodel. The title and subtitle are just properties of that QObject. So if my property was called firstname, then the code would be ListItemData.firstname.

 

About the index of the listview position, I'm not sure about that. Tried a couple of things here but no succes yet. If I find something, I'll keep you posted.

______________________________________________________
BB10-OAuth: GitHub