If you are using Internet Explorer, please remove blackberry.com from your compatibility view settings.

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
AVPTI
Posts: 64
Registered: ‎06-28-2011
My Device: BlackBerry Z10
My Carrier: Bell
Accepted Solution

SegmentedControl question

I have a SegmentedControl setup with two options.

 

Depending on the option chosen, I want to load a different XML list.

 

Is it possible? If so how?

 

I've looked at the bucketlist sample and the JSON file is confusing me (fairly new to developing)

 

Thanks for your time

Please use plain text.
Developer
Developer
lew
Posts: 174
Registered: ‎03-05-2009
My Device: Dev Alpha
My Carrier: -

Re: SegmentedControl question

Here goes:

 

SegmentedControl {
    id: segmented1
    Option {
        id: option1
        text: "option 1"
        value: "option1"
        selected: true
    }
    Option {
        id: option2
        text: "option 2"
        value: "option2"
    }
    onSelectedIndexChanged: {
// detects that option has changed or not var value = segmented1.selectedValue() console.debug("Selected value: " + value); if(value = "option1") dataSource1.load() else dataSource2.load() } } ... ListView { id: listView } ... attachedObjects:[ ... DataSource { id: dataSource1 onDataLoaded: { listView.dataModel.clear(); listView.dataModel.insertList(data); } } ... DataSource { id: dataSource2 onDataLoaded: { listView.dataModel.clear(); listView.dataModel.insertList(data); } } ... ]

 

read more about datasources here if you are not familiar with it:

https://developer.blackberry.com/cascades/reference/bb__data__datasource.html

 

hope it helps!

Please use plain text.
Developer
AVPTI
Posts: 64
Registered: ‎06-28-2011
My Device: BlackBerry Z10
My Carrier: Bell

Re: SegmentedControl question

Thanks for that.

 

How do I connect the DataSource to different XML's to view as a list?

 

And again, thanks for you help and time!

Please use plain text.
Developer
Developer
lew
Posts: 174
Registered: ‎03-05-2009
My Device: Dev Alpha
My Carrier: -

Re: SegmentedControl question

read the documentation:

https://developer.blackberry.com/cascades/documentation/device_platform/data_access/using_data_sourc...

 

you simply have to tweak the code i posted above

Please use plain text.
Developer
AVPTI
Posts: 64
Registered: ‎06-28-2011
My Device: BlackBerry Z10
My Carrier: Bell

Re: SegmentedControl question

How do I install the bb.data?

 

says it can't open QML because bb.data isn't installed?

Please use plain text.
Developer
Developer
lew
Posts: 174
Registered: ‎03-05-2009
My Device: Dev Alpha
My Carrier: -

Re: SegmentedControl question

please check the documentation again:

(and try the samples)

 

you need to add the following to your .pro file:

The DataSource class and other supporting classes are included in the bb::data library. To use these classes in your apps, you need to add the following line to the .pro file in your project:

 

LIBS += -lbbdata

 then in your QML:

import bb.data 1.0

 

 

 

Please use plain text.
Developer
AVPTI
Posts: 64
Registered: ‎06-28-2011
My Device: BlackBerry Z10
My Carrier: Bell

Re: SegmentedControl question

I did both and still get the "Problem loading QML file: 2:1: module "bb.data" is not installed"

 

Here is my .pro, maybe I put it in the wrong area? I put it in the same spot as the buketlist.pro

 

TEMPLATE = app

TARGET = DataSource

CONFIG += qt warn_on debug_and_release cascades

LIBS += -lbbdata

INCLUDEPATH += ../src
SOURCES += ../src/*.cpp
HEADERS += ../src/*.hpp ../src/*.h

lupdate_inclusion {
SOURCES += ../assets/*.qml
}

device {
CONFIG(release, debug|release) {
DESTDIR = o.le-v7
}
CONFIG(debug, debug|release) {
DESTDIR = o.le-v7-g
}
}

simulator {
CONFIG(release, debug|release) {
DESTDIR = o
}
CONFIG(debug, debug|release) {
DESTDIR = o-g
}
}

OBJECTS_DIR = $${DESTDIR}/.obj
MOC_DIR = $${DESTDIR}/.moc
RCC_DIR = $${DESTDIR}/.rcc
UI_DIR = $${DESTDIR}/.ui

suredelete.target = sureclean
suredelete.commands = $(DEL_FILE) $${MOC_DIR}/*; $(DEL_FILE) $${RCC_DIR}/*; $(DEL_FILE) $${UI_DIR}/*
suredelete.depends = distclean

QMAKE_EXTRA_TARGETS += suredelete

TRANSLATIONS = \
$${TARGET}_en_GB.ts \
$${TARGET}_fr.ts \
$${TARGET}_it.ts \
$${TARGET}_de.ts \
$${TARGET}_es.ts \
$${TARGET}.ts

Please use plain text.
Developer
Developer
lew
Posts: 174
Registered: ‎03-05-2009
My Device: Dev Alpha
My Carrier: -

Re: SegmentedControl question

is that error in the QML Previewer? If so this is a known issue, test directly on device/simulator.

 

Please use plain text.
Developer
AVPTI
Posts: 64
Registered: ‎06-28-2011
My Device: BlackBerry Z10
My Carrier: Bell

Re: SegmentedControl question

oh. OK.

 

Thanks for all your help and sorry for the silly questions!

Please use plain text.
Developer
Developer
lew
Posts: 174
Registered: ‎03-05-2009
My Device: Dev Alpha
My Carrier: -

Re: SegmentedControl question

yw :smileyhappy: mark it as resolved if it's working fine now ;-)

Please use plain text.