Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
johnmarsden
Level 7

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?
0 Kudos
6 Replies
tim_beynart
Level 7

Re: Passing data from RowList to the itemComponentName?

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.
0 Kudos
johnmarsden
Level 7

Re: Passing data from RowList to the itemComponentName?

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).
0 Kudos
tim_beynart
Level 7

Re: Passing data from RowList to the itemComponentName?

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.
0 Kudos
drinkrain
Level 7

Re: Passing data from RowList to the itemComponentName?

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?
0 Kudos
joetesta
Level 10

Re: Passing data from RowList to the itemComponentName?

https://sdkdocs.roku.com/display/sdkdoc ... LComponent
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."
aspiring
0 Kudos
drinkrain
Level 7

Re: Passing data from RowList to the itemComponentName?

"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.
0 Kudos