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

Please Explain Nature of MarkupGrid

Ok, my initial problem, making off screen grid content come into focus,  is detailed https://forums.roku.com/viewtopic.php?f=34&t=99550 which I found some what of a solution. The solution causes a second problem that really baffles.  The setup, a markupgrid with 4 visible columns, 4 rows and a total of 10 columns. When grid loads, all 4 columns and rows populate as planned. As the grid is traversed and the 4th column is reached, the following code, which defines the column widths,  is executed:

m.columnFocused=m.ProgramMarkupGrid.itemFocused MOD m.ProgramMarkupGrid.numColumns
temp=[]
IF  m.columnFocused = 3 or m.columnFocused= 6 or m.columnFocused = 8
counter= m.columnFocused - 1
for i= 0 to m.programmarkupgrid.numcolumns - 1
         if i <= counter
         temp[i]= -2         'use -2 to prevent content overlap, 0 doesn't work
         else
         temp[i]= 312        'set column width to 312
         end if
  end for
else
temp=m.programmarkupgrid.columnwidths
end if
?"column focus "m.columnFocused
?"Content Item "m.ProgramMarkupGrid.itemFocused
?"row focused "m.rowFocused
?temp
m.ProgramMarkupGrid.columnwidths=temp

 As the focus reaches 3 (4th column) previous cell widths set to -2 and others to 312. This continues across the grid.
Problem: If focus is changed from Row 0 to any other row and the focus has extended past 4th column,  the content disappears from the grid. Scrolling to any row other than 0 and it vanishes. If I start in Row 0, scroll to column 5, everything is visible, if I scroll down to Row 1 in column 5, all vanishes. I can scroll to Row 2 or Row 3 and still gone. If I scroll back to Row 0, the content for Rows 1,2 3 reappears. So, in effort to figure this out I tried many things, one being setting the temp = 0 instead of -2. Well, the content shows up but you are left with the first column with content overlap.  I have also used a for print statment at end of code to check if there was content. I can run it, scroll all day, the content correctly shows up in debugger but never on screen unless the value is 0 instead of -2. The -2 is what I discovered makes the left side of the grid columns completely go away so there is no overlap or cell collision,  As I move back to Row 0 and the content reappears, it's almost as it's rolled up from the bottom of the grid, as if it were pushed down off the grid.
Question: Is there any other methods of scrolling a markupgrid that doesn't require changing cell widths? If so please share. If not, has anybody else had the problem as described? I really can't see a problem with the code that would cause a Row change to effect it as it does.
0 Kudos
5 REPLIES 5
joetesta
Roku Guru

Re: Please Explain Nature of MarkupGrid

scrolling a markupgrid that doesn't require changing cell widths


 know I've seen this working, can you just keep the cells full width and let them flow offscreen (using Animation on translation)?
Or perhaps more clearly, instead of changing the widths of each cell, change the translation of the entire grid?
aspiring
0 Kudos
btpoole
Channel Surfer

Re: Please Explain Nature of MarkupGrid

 I know the columns exist past what is visible on the screen and with code modification I can scroll all the columns. The only way I could get the off screen column content to show up was set the preceding columns to a negative width. For some reason doing this messes with the rows after Row 0. Would think a grid would have the ability to bring off screen into focus. Kinda at a loss. Thanks for the suggestion.
0 Kudos
joetesta
Roku Guru

Re: Please Explain Nature of MarkupGrid

OK how about this idea, you have two grids with all the same content and alter the 'visible' property of each contentnode (of the individual grid cells) appropriately.  GridA will have the first columns visible until the user goes right 4 times then GridA will have its cells with index > 3 set to visible = false, and GridB which should be offset one column width to the left from GridA will have columns index > 4 set to visible.  Then as the user continues to scroll right, you translate GridB to the left and set the visible property of the previously leftmost visible column of GridB to false..  Make sense?
aspiring
0 Kudos
btpoole
Channel Surfer

Re: Please Explain Nature of MarkupGrid

Well, I was kinda of starting to think like that but trying to avoid it it possible. But always an option I guess.  Was considering multiple grids then thought about maybe using getchild() to reset the content of the grid to see what that might do.  Odd thing is that I know it can be done, have seen it move cells (1 at time) on the epggrid component that exist. Not completely sure but from what I can tell looks like that component is shrinking cells. Thanks again
0 Kudos
btpoole
Channel Surfer

Re: Please Explain Nature of MarkupGrid

Solved. In order to scroll a grid without changing column widths and moving cells, I am slicing the content node and resetting the grid content. Now as user scrolls left to right and hits last visible column, grid is populated with new content.  Did take a while to figure out how to keep focus on current row, it always wanted to set focus back to 0,0.

Edit:
Not satisfied with my method of slicing the content node, I went back to the adjusting column widths. I discovered that to prevent the content collision and prevent information after the first row from disappearing, I needed to adjust the itemspacing of grid. So in the code mentioned at the very top of the thread, I added in tempspacing=[0,6] and set the grid property to the tempspacing array. Works as it's suppose to.
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.