create listView with certain items from array
-
Hello!
I am trying to create a listView of names on selected calendar date(s), which if the date in the calendar matches, will display the userName in the listView;
My array is created from a firebase read on userLogin, and using the for loop and image visibility i am adding a marker to dates in the array, how could i amend the loop or what would i add to as my ListModel to show this?
I have tried many variations of things such as
List View { model: arrayFromFireBase delegate: Text {text: modelData.name } }
But am struggling to get it working! below is the code which applies to adding the date marker to my calendar, I am wondering if I need to alter the loop to apply to the
name
property also as my array looks like[{"name":"Edward","date":"2018-06-12"},{"name":"Dave","date":"2018-09-10"},{"name":"Tom","date":"2018-06-12"}]
in the console. from This on the 6/12/18 there would be two names in the listView (Edward&Tom), whereas just the one name (Dave) on the 10/9Any help would be amazing!!!
ThanksMain.qml:
App { property var arrayFromFireBase: [] onLoggedIn: { firebaseDb.getUserValue("dates/selectedDates", {}, function(success, key, value) { if(success) { for(var idx in value) arrayFromFireBase.push(new Date(value[idx].date).getTime()) })}}
CalendarPage.qml: Page { AppButton { id: saveButton text: "Save & Request" onClicked: { userData.selectedDates.push({"date": calendar.selectedDate}); console.log(JSON.stringify(userData)); firebaseDb.setUserValue("dates", userData) } } property var userData: { "selectedDates": [{}] } Image { visible: arrayFromFireBase.indexOf(styleData.date.getTime()) > -1 } }