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
New Developer
oumaimaBlueWave
Posts: 8
Registered: ‎03-11-2014
My Device: dev alpha B
My Carrier: blackberry

listView/ group datModel doesn't show the header

hi, I need to fill a dynamic listView. So I fill his groupdattamodel for the c++ file.
The items are displayed successfully bur I have a problem with header. (it's always empty)
there is the above code:
the qml file:

 ListView {

            dataModel: groupDataModel
            layout: StackListLayout {
                headerMode: ListHeaderMode.Standard

            }
            maxHeight: verticalAlignment.Fill
            maxWidth: horizontalAlignment.Fill

            listItemComponents: [
                ListItemComponent {
                    id: header
                    type: "header"
                    Header {
                        id: listSettingsHeader
                        objectName: "header"
                        title: ListItemData.headerTitle
                      
                    }

                },
                ListItemComponent {
                    id: item
                    type: "item"

                    SettingsItem {
                        id: settingItem
                        itemSettingsDescription: ListItemData.itemSettingDescription
                        itemSettingsLabel: ListItemData.itemSettingsLabel
                        isEnabled: ListItemData.isEnabled
                        isVisible: ListItemData.visible
                        isChecked: ListItemData.isChecked

                    }
                }
            ]

            onTriggered: {
                var selectedItem = dataModel.data(indexPath);
                if (selectedItem.isEnabled)
                    _settingsDelegate.onClickItem(selectedItem.itemSettingsLabel)

            }

            animations: [
                SequentialAnimation {
                    id: sequential
                    TranslateTransition {
                        id: mtranslateAnimation
                        duration: 1000
                        fromX: 0
                        toX: 100
                    }
                    FadeTransition {
                        id: mRotateAnimation
                        duration: 1000
                        fromOpacity: 1.0
                        toOpacity: 0.2
                    }
                }
            ]
            accessibility.name: "list settings"

            attachedObjects: [
                // Add the data model as an attached object. Make sure
                // to specify a value for the objectName property,
                // which is used to access the model from C++.

                GroupDataModel {
                    id: groupDataModel
                    objectName: "SettingsDataModel"
                }
            ]
        }

 


 and the cpp file:

m_settingsListModel = root->findChild<GroupDataModel*>("SettingsDataModel");

m_settingsListModel->setSortingKeys(
			QStringList() << "headerTitle" << "number " << "itemSettingsLabel"
					<< "itemSettingDescription" << "visible" << "isEnabled"
					<< "isChecked");

QStringList acountSettings;

	//login
	acountSettings << "user settings" << "1" << "LOGIN"
			<< g_savedUser->getUserName() << "false" << "false" << "false";
	addItemtoListView(acountSettings);

	//password
	acountSettings.clear();
	acountSettings << "user settings" << "1" << "PASSWORD" << "*********"
			<< "false" << "false" << "false";
	addItemtoListView(acountSettings);

	//remember password
	acountSettings.clear();
	acountSettings << "user settings" << "1" << g_labelsList->rememberUserHeader
			<< "disable credible registration" << "true" << "true"
			<< g_appSettings.value("rememberMecChb", true).toString();
	addItemtoListView(acountSettings);

QStringList PreferencesSettings;
	//product language
	if (g_applicationConfig->languageSettingActivated()) {
		PreferencesSettings << "Language parametres" << "2"
				<< g_labelsList->productLaunguageHeader
				<< g_savedUser->getUserLangue() << "false" << "true" << "false";
		addItemtoListView(PreferencesSettings);
	}
	if (g_applicationConfig->currencySettingsActivated()) { //Currency
		PreferencesSettings.clear();
		PreferencesSettings << "Currency parameteres" << "3"
				<< g_labelsList->CurrencyHeader << g_savedUser->getCurrency()
				<< "false" << "true" << "false";
		addItemtoListView(PreferencesSettings);
	}
	if (g_applicationConfig->dateFormatSettingActivated()) {
		//date
		PreferencesSettings.clear();
		PreferencesSettings << "Date settings" << "4"
				<< g_labelsList->DateFormatHeader
				<< g_savedUser->getDateFormat() << "false" << "true" << "false";
		addItemtoListView(PreferencesSettings);
	}
	if (g_applicationConfig->unitSettingActivated()) {
		//volume unit
		PreferencesSettings.clear();
		PreferencesSettings << "Unit parameteres" << "5"
				<< g_labelsList->VolumeUnitHeader
				<< g_savedUser->getVolumeUnit() << "false" << "true" << "false";
		addItemtoListView(PreferencesSettings);

  so there is another way to fill the title of the header ?? thankyou

Please use plain text.
Developer
strobejb
Posts: 267
Registered: ‎10-15-2012
My Device: bb10 developer
My Carrier: Orange

Re: listView/ group datModel doesn't show the header

Header {
title: ListItemData
}
Please use plain text.
New Developer
oumaimaBlueWave
Posts: 8
Registered: ‎03-11-2014
My Device: dev alpha B
My Carrier: blackberry

Re: listView/ group datModel doesn't show the header

I tried it but ListItemData returns the first Letter and I need all the string :smileysad: :smileysad:

Please use plain text.
Developer
pyth
Posts: 504
Registered: ‎01-19-2011
My Device: My Trusty Red Plane
My Carrier: Outer Space

Re: listView/ group datModel doesn't show the header

Just add a grouping to your GroupDataModel

 

https://developer.blackberry.com/native/reference/cascades/bb__cascades__groupdatamodel.html#propert...

 

 

Alternatively, you can add a function to your ListView, which defines what is header and what is item

 

function itemType(data, indexPath) {
        return (indexPath.length == 1 ? 'header' : 'item');
    }

 

https://developer.blackberry.com/native/reference/cascades/bb__cascades__listview.html

 

per default, the listview uses the itemType of the datamodel. Since you are using a groupDataModel, but don't group, there are no headers

-----------------------------------------------------------------------
I'm a bird from outer space. But I'm not flappy o.o
Please use plain text.
New Developer
oumaimaBlueWave
Posts: 8
Registered: ‎03-11-2014
My Device: dev alpha B
My Carrier: blackberry

Re: listView/ group datModel doesn't show the header

It doesn't work also. I didn't focus where is the problem exactly :smileysad:

Please use plain text.
Developer
pyth
Posts: 504
Registered: ‎01-19-2011
My Device: My Trusty Red Plane
My Carrier: Outer Space

Re: listView/ group datModel doesn't show the header

[ Edited ]

could you post a screenshot of your current view?

-----------------------------------------------------------------------
I'm a bird from outer space. But I'm not flappy o.o
Please use plain text.
New Developer
oumaimaBlueWave
Posts: 8
Registered: ‎03-11-2014
My Device: dev alpha B
My Carrier: blackberry

Re: listView/ group datModel doesn't show the header

Screenshots

as the pictures shows, the header is empty

Please use plain text.