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
Posts: 24
Registered: ‎07-21-2010
My Device: Z10
My Carrier: T-Mobile

Cascades - DataSource.source

[ Edited ]

Hello all,

 

I need help in my dev, I'm feeling stuck.

my developement is in Cascades and new to BB Native.

Here is my code

import bb.cascades 1.2
import bb.data 1.0



Page {
    id: topPage
    property string id1 
    property string title1
   
    //property string id1
    
  
    titleBar: TitleBar {
        // Localized text with the dynamic translation and locale updates support
        title: qsTr(title1) + " - Cast" + Retranslate.onLocaleOrLanguageChanged
    }

 I pushed this QML from another, I'm getting title1 and i'm showing that as title here thats working fine.

   DataSource {
            id: dataSource
            source: id1 // this is the variable pushed
            type: DataSourceType.Json
            query: "/cast" // You'll need to add a root node to you file
            onDataLoaded: {
                dataModel.clear()
                dataModel.insertList(data.cast)
            }

 but the problem is id1 is always blank, but id1 value has been pushed from the previous qml. but i was not able to access from this point. 

 

Please help

Pavan

 

Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: Cascades - DataSource.source

Hi!
Is it being pushed from ListView? If so, ListView's ListItemComponents have different context and require this workaround:

http://supportforums.blackberry.com/t5/Native-Development/ActionItem-issue-in-a-context-menu/m-p/217...
(define a function at ListView level to return the title1 and call this function from ListItemComponent)

Or pass the title via a global variable as shown here:
http://supportforums.blackberry.com/t5/Native-Development/QML-Accessing-variables-defined-outside-a-...

If this is a different issue, please post all the relevant code so we can see the path from title1 declaration to the place where it's being used.

Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 24
Registered: ‎07-21-2010
My Device: Z10
My Carrier: T-Mobile

Re: Cascades - DataSource.source

Hi

Thanks for your reply, I'm not pushing from list view

See here is the code which push the variables and page

    actions: [
        ActionItem {
	        title: qsTr("Cast") + Retranslate.onLocaleOrLanguageChanged
	        imageSource: "asset:///images/icons/castwhite_large.png"
	        ActionBar.placement: ActionBarPlacement.OnBar
	        
	        onTriggered: {
                var page1 = getCastPage.createObject();
                page1.id1 = id1
                page1.title1 = title1
                navigationPane.push(page1);   
	        }
	        attachedObjects: [ 
	            ComponentDefinition {
	                id: getCastPage
	                source: "actors.qml"
	            }            
	        ]        
         },

 With the above code I'm pushing id1 and title1. 

I dont have any issues with title1 becuase, I'm using that to set the page title and its working fine

When it comes to id1, then this variable is blank, my idea is that again i need to show list view based on the id1 value, basically its url, so that i can make DataSource and show it in list view.

 

And here is the pushed page actors.qml

import bb.cascades 1.2
import bb.data 1.0



Page {
    id: topPage
    property string id1 
    property string title1
  
    titleBar: TitleBar {
        title: qsTr(title1) + " - Cast" + Retranslate.onLocaleOrLanguageChanged
    }

    Container {
       
        ListView {
            dataModel: dataModel
            horizontalAlignment: HorizontalAlignment.Fill
            verticalAlignment: VerticalAlignment.Fill
            listItemComponents: [
                ListItemComponent {
                    type: "item"
                    StandardListItem {
                        imageSpaceReserved: false
                        title: ListItemData.name
                        description: ListItemData.noofmovies
                    }
                }  
            ]  
        }
         
    }
    
    attachedObjects: [
        
        
        GroupDataModel {
            id: dataModel
            sortedAscending: false
            grouping: ItemGrouping.None
        },
        
        DataSource {
            id: dataSource
            source: "http://myurl.com?cinetalkID=" + id1 
            type: DataSourceType.Json
            query: "/cast" // You'll need to add a root node to you file
            onDataLoaded: {
                dataModel.clear()
                console.debug("PAVAN-> Data being inserted");
                console.debug(data.cast);
                dataModel.insertList(data.cast)
            
            }
        }
    ]
    onCreationCompleted: {
        dataSource.load()
        console.debug("Pavan - JSON Loaded");
    }    
}

 

Thanks in Advance

Developer
Posts: 24
Registered: ‎07-21-2010
My Device: Z10
My Carrier: T-Mobile

Re: Cascades - DataSource.source

Any Help
Developer
Posts: 24
Registered: ‎07-21-2010
My Device: Z10
My Carrier: T-Mobile

Re: Cascades - DataSource.source

Bump