Binding data to ListView
How do I feed the data into the generated child widgets?
What I've tried / done so far:
(I refer to this widget, if you're wondering)
I have a widget called
"Binding" data to a List View widget seems pretty straightforward, you just call
But the problem is that the list view does not know how to translate the data from the list into the widgets. Even tho that
Disclaimer: I already know that you can make a scrollable list by placing widgets, this is about List View widget.
asked Jan 03 '19 at 08:37 PM in Blueprint Scripting
You don't add the widgets to the list directly, instead you create an Object blueprint which will contain the data you want. And when adding an item to the list you construct that object and add it. For it to use your widget, set the Entry Widget Class, to your widget, in the details panel of the List View
So, make a new Blueprint class, pick Object as its parent class (not Actor). In this class add all the variables you need. Set them as Editable and Exposed On Spawn:
Then, in your widget which will be the entry, make sure you have implemented the User Object List Entry interface. In the event graph, right click and find the "Event On List Item Object Set". The object passed in this event is the one you created above, but you'll need to cast it to your class first to access the variables. You can then use those variables to set the text in your widget or whatever you want to do with the data. Like this for example:
And finally, to actually add entries you use Construct Object, construct an object of the the same class you created above, here you can plug in whatever values you want, and then use Add Item to add it your list. The List handles creating the widgets themselves, it just needs the data.
You could probably iterate through your inventory items and construct add the data objects like I did here:
I'm using tile view but it's the same idea. I have found the selection bit of tile views are a bit buggy though, at least in 4.21.
answered Jan 03 '19 at 08:54 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here