just copy the code into main.qml and you can see a groupdatamodel implementation
import bb.cascades 1.0
Page {
content: Container {
attachedObjects: [
GroupDataModel {
id: groupDataModel
// Sort the data items based first on country name, and
// then by city name (if the country names are equal)
sortingKeys: [
"countryName",
"cityName"
]
// Specify that headers should reflect the full value
// of the sorting key property, instead of just the
// first letter of the property
grouping: ItemGrouping.ByFullValue
}
]
ListView {
dataModel: groupDataModel
// After the list is created, add the data items
onCreationCompleted: {
groupDataModel.insert({
"countryName": "India",
"cityName": "New Delhi"
});
groupDataModel.insert({
"countryName": "India",
"cityName": "Mumbai"
});
groupDataModel.insert({
"countryName": "India",
"cityName": "Bangalore"
});
groupDataModel.insert({
"countryName": "India",
"cityName": "Hyderabad"
});
groupDataModel.insert({
"countryName": "India",
"cityName": "Chennai"
});
groupDataModel.insert({
"countryName": "India",
"cityName": "Lucknow"
});
groupDataModel.insert({
"countryName": "India",
"cityName": "Patna"
});
groupDataModel.insert({
"countryName": "Bangladesh",
"cityName": "Khulna"
});
groupDataModel.insert({
"countryName": "Bangladesh",
"cityName": "Dhaka"
});
groupDataModel.insert({
"countryName": "Bangladesh",
"cityName": "Chitagong"
});
groupDataModel.insert({
"countryName": "Pakistan",
"cityName": "Karachi"
});
groupDataModel.insert({
"countryName": "Pakistan",
"cityName": "Hyderabad"
});
groupDataModel.insert({
"countryName": "Bangladesh",
"cityName": "Lahore"
});
}
} // end of ListView
} // end of Container
}// end of Page
import bb.cascades 1.0
Page {
content: Container {
attachedObjects: [
GroupDataModel {
id: groupDataModel
// Sort the data items based first on country name, and
// then by city name (if the country names are equal)
sortingKeys: [
"countryName",
"cityName"
]
// Specify that headers should reflect the full value
// of the sorting key property, instead of just the
// first letter of the property
grouping: ItemGrouping.ByFullValue
}
]
ListView {
dataModel: groupDataModel
// After the list is created, add the data items
onCreationCompleted: {
groupDataModel.insert({
"countryName": "India",
"cityName": "New Delhi"
});
groupDataModel.insert({
"countryName": "India",
"cityName": "Mumbai"
});
groupDataModel.insert({
"countryName": "India",
"cityName": "Bangalore"
});
groupDataModel.insert({
"countryName": "India",
"cityName": "Hyderabad"
});
groupDataModel.insert({
"countryName": "India",
"cityName": "Chennai"
});
groupDataModel.insert({
"countryName": "India",
"cityName": "Lucknow"
});
groupDataModel.insert({
"countryName": "India",
"cityName": "Patna"
});
groupDataModel.insert({
"countryName": "Bangladesh",
"cityName": "Khulna"
});
groupDataModel.insert({
"countryName": "Bangladesh",
"cityName": "Dhaka"
});
groupDataModel.insert({
"countryName": "Bangladesh",
"cityName": "Chitagong"
});
groupDataModel.insert({
"countryName": "Pakistan",
"cityName": "Karachi"
});
groupDataModel.insert({
"countryName": "Pakistan",
"cityName": "Hyderabad"
});
groupDataModel.insert({
"countryName": "Bangladesh",
"cityName": "Lahore"
});
}
} // end of ListView
} // end of Container
}// end of Page
No comments:
Post a Comment