Forum Discussion

johnmarsden's avatar
9 years ago

Passing data from RowList to the itemComponentName?

My RowList class script has a few custom variables I want to pass into each RowListItem when they're created. It's not about content, but about theme/size/etc. 

What's the proper way to pass a bit of custom data to all instantiated items within a RowList? 
Is there some sort of "onItemCreated" event where we can see the instance?

6 Replies

  • Why do you need the data when the item is created? For information that's not available until render time, one solution is to apply it when an item is selected on itemFocused or itemSelected events.
  • It can't be at selection or focus. It's about theming, colors, size, etc. 

    Defining different types of RowLists won't do the trick. I need to pass custom data to the individual component items at instantiation (or immediately after).
  • itemComponentName lets you define a component to use as the individual rowlist items. You could use the init() function of the component to do stuff, though I am not sure how you would pass anything into it.
  • Has anybody found a solution to passing data to an itemComponentName?
    I have worked around this by adding to the itemContent's metadata. Also I have used the global scope.  
    I would much prefer to pass data through a specific field however.
    Ideas anybody?
  • "joetesta" wrote:
    https://sdkdocs.roku.com/display/sdkdoc/MarkupList#MarkupList-MarkupListXMLComponent
    Sounds like you could add a field / fields to the itemContent and use that field
    "Typically, an observer of the itemContent field is used to update the list item when the content changes."

    I am trying to avoid this because when I update the itemContent the parents observer fires because the parent is observing the same content.  To me it would make more sense to pass a separate field down to it.