Hey!
I’ve Have a JonListModel, used together with the SortFilterProxyModel; This model & listview are used multiple times on a single page, via a repeater (they’re horizontal scrolls).
What I am looking to achieve is each row has a different expression filter active – as this is an ‘explore’ section; I am able to apply a single filter across all lists, however without having to include several coded lists one the page I was hoping to be able to just adjust the same one each time is appears, code below:
HomePage.qml
property var arr: [{"hair": "Hairstylists"},{"mua": "Makeup Artists}]
Column {
id: content
width: parent.width
Repeater {
id: repeater
model: arr.length
Rectangle {
width: parent.width
height: parent.height / 3
Column {
id: contentCol
anchors.fill: parent
AppText {
text: Object.values(arr[index]) // the Object.key of my 'index' is what i wish to use as the filter for each row, passed over to 'HomeFlickable{ }'
}
HomeFlickable { }
}
}
}
}
HomeFlickable.qml
JsonListModel {
id: jsonModel
source: feed2
keyField: "id"
fields: ["id", "owner", "tag"]
}
SortFilterProxyModel {
id:sortedModel
Component.onCompleted: sourceModel = jsonModel
filters: ExpressionFilter {expression: model.tag === "makeup"} //this obviously filters those with a defined tag
}
From the above example, when defining the filter “makeup” it works as you would expect, however what I am looking to do is somehow take the Object.keys() of ‘arr’ and apply that as the filter in ‘HomeFlickable’ for each time it is loaded!
Thanks