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: 
Hannah15
Reel Rookie

How can we set custom fields in the MarkupGrid XML component?

Jump to solution

The MarkupGrid node has a field called 'itemComponentName'. This should be set to the name of a custom XML component. It is used to display each item in the grid

For this XML Component, there are a few fields mentioned in the documentation. If we set fields of the same name, their values are populated by the content given to the MarkupGrid Node. 
But how do we set custom fields of the XML Component?

This is all the SceneGraph documentation has to say on the matter:
"If the XML component contains interface fields that match the names shown in the table below, those fields will be updated by the MarkupGrid node."
ref: https://developer.roku.com/docs/references/scenegraph/list-and-grid-nodes/markupgrid.md#markupgrid-x... 

For example purposes, we'll call the MarkupGrid node 'grid1' and the xml component 'itemTemplate'.

<MarkupGrid 
    id = "grid1" 
    itemComponentName = "itemTemplate"
/>


Since the XML component is not directly included as a node in the xml file, we cannot access it like we usually do i.e.,
m.itemTemplate = m.top.findNode("itemTemplate")

Sow how can we set values for custom fields of the itemTemplate node?

A current use case I need this for is to pass the index of the focused item to the XML component from the MarkupGrid. And there is no default field for this according to documentation.

0 Kudos
1 Solution

Accepted Solutions
Chris-DP
Binge Watcher

Re: How can we set custom fields in the MarkupGrid XML component?

Jump to solution

You can't set fields yourself on your item components. If there is extra data you need to give them you would usually add this to the content nodes that your items will receive from the Grid.  

View solution in original post

4 REPLIES 4
Chris-DP
Binge Watcher

Re: How can we set custom fields in the MarkupGrid XML component?

Jump to solution

You can't set fields yourself on your item components. If there is extra data you need to give them you would usually add this to the content nodes that your items will receive from the Grid.  

Hannah15
Reel Rookie

Re: How can we set custom fields in the MarkupGrid XML component?

Jump to solution

Oh interesting.
So if we added them to the content node using a key 'val23', and then created a field on the item component with the same id as the key, the content node should set the field?

0 Kudos
Chris-DP
Binge Watcher

Re: How can we set custom fields in the MarkupGrid XML component?

Jump to solution

No but your comment can read the new field off the content node. 

Value = m.top.itemContent.val23

Hannah15
Reel Rookie

Re: How can we set custom fields in the MarkupGrid XML component?

Jump to solution

Thank you! This has cleared it up.

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.