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

SceneGraph move from multi row grid to single row grid(SimpleGridWithDetailsAndVideo example)

I am trying to learn SceneGraph. I have been manipulating the SimpleGridWithDetailsAndVideo sample and have been able to make some changes. I have the first grid as a standard full-screen grid and make it so that if you click on an item in the grid the user is brought to a different grid that includes an image preview at the top of the screen along with the description. I also have been able to load in different content than what is provided.

I would like this second grid screen to only contain a single row from the first grid screen. Currently, the content is set with: 
m.gridScreen2.content = m.gridScreen.content


I have been digging through and experimenting with this node but I have been unable to find a way set only a single row to my grid content.  :shock:

How can I set only a single row in my second grid? Can I reference a single row of the grid content from this example? :?:

Thank you very much for taking the time to read this. Any information at all is very appreciated.  🙂  🙂

:?ps: I have tried just running a new function in HomeScreen to pull in the single row that I want but I am running into thread problems. Apparently, you can't do a lot of things in these scene functions. If you have any information on this front it would also be very appreciated. For example, how would I reference a function from another brs file from the OnRowItemSelected() function in the HomeScene brs? :?: I think the answer is you can't but I am confused at what the flow should be for this. I don't know what I want until the user clicks. 
0 Kudos
4 REPLIES 4
joetesta
Roku Guru

Re: SceneGraph move from multi row grid to single row grid(SimpleGridWithDetailsAndVideo example)

Haven't tested it but think this would work:

contentNode = createObject("RoSGNode","ContentNode")
row1 = m.gridScreen.content.getChild(0)
contentNode.appendChild(row1)
m.gridScreen2.content = contentNode


how would I reference a function from another brs file from the OnRowItemSelected() function in the HomeScene brs?

You can include that other brs file in the HomeScene's XML, https://forums.roku.com/viewtopic.php?f=34&t=105446
aspiring
0 Kudos
lock_4815162342
Channel Surfer

Re: SceneGraph move from multi row grid to single row grid(SimpleGridWithDetailsAndVideo example)

Thank you so much for the advice. It has been very helpful.

I am running into an issue. When I append the child to contentNode it removes the child from m.gridScreen.content. I am confused as to why this is happening. I checked and it is not being removed when I only run getChild() it is the appendChild() that is removing it. It doesn't seem like this is something that should be happening. 

Can you give me an idea why this is happening? Is there another method that would be better to use?

Thank you for taking the time to read this. Any information will be very appreciated. 
0 Kudos
lock_4815162342
Channel Surfer

Re: SceneGraph move from multi row grid to single row grid(SimpleGridWithDetailsAndVideo example)

As an added note, I thought that I would be slick and just add the child back to the original gridScreen. To my surprise when I do this it removes the child or row from gridScreen2. It seems that the child can only exist in one place. I also tried setting the child to a different variable and I got the same results. 

Is there a way to clone a child so that it can be used in more than one place? Am I just going about this all wrong? :shock:

Thank you for taking the time to read this. Any information that you can offer will be very appreciated.  🙂
0 Kudos
joetesta
Roku Guru

Re: SceneGraph move from multi row grid to single row grid(SimpleGridWithDetailsAndVideo example)

yes it's because nodes are always "passed by reference" meaning there is only one instance of any given node and when you set a variable equal to the node, it's really just a pointer.  There are workarounds such as copying the non-node contents bit by bit, or retaining the original data and regenerating a new node from it.
aspiring
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.