Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
johnmarsden
Visitor

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 6
tim_beynart
Channel Surfer

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
Visitor

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
Channel Surfer

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
Visitor

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
Roku Guru

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
Visitor

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
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.