Roku Developer Program

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

Re: Refresh Grid View

Here's a more detailed view of the problem. below is the sub that runs for find the child and replacechild. This is the replace for the first grid I have. The second grid is called PickList. I don't have the code for it here since when it runs after MyGrid (refreshContent sub) the child is gone, so it disappears from screen.

sub refreshContent()
?"in refreshContent""MyGrid")
for i = 0 to
  child =
  ?"CHILD ""   "i
  if = "MyGrid"  
    ?"MyGrid INDEX  "i
    exit for
  end if
end for

  m.MyGrid.content = ,i)
  ?"REPLACEMENT  " ,i)
m.programmarkupgrid.visible= true
for q= 0 to - 1
?"CHILD  "
end for

Ok, I am not creating a new child, but setting the content to new content that was downloaded. 

Below is the debug from the initial for loop thru the children. Notice it finds MyGrid at 15. Also not PickList at 14.

in refreshContent
in setColumnWidth--
CHILD     0
CHILD blank    1
CHILD UpdateGridContent    2
CHILD     3
CHILD background    4
CHILD TopLogo    5
CHILD instructLabel    6
CHILD Background    7
CHILD ActivationDate    8
CHILD Message    9
CHILD theMessage    10
CHILD MessageBackground    11
CHILD favoriteList    12
CHILD ImageList    13
CHILD PickList    14
CHILD MyGrid    15
MyGrid INDEX   15
in onFocusChanged

Here is the debug widnow for the loop after the replace has taken executed.  Note PickList is no longer a child and index is changed.
CHILD     0
CHILD  blank   1
CHILD  UpdateGridContent   2
CHILD     3
CHILD  background   4
CHILD  TopLogo   5
CHILD  instructLabel   6
CHILD  Background   7
CHILD  ActivationDate   8
CHILD  Message   9
CHILD  theMessage   10
CHILD  MessageBackground   11
CHILD  favoriteList   12
CHILD  ImageList   13
CHILD  MyGrid   14
CHILD  currenttimedate   15
CHILD  gridline_top   16
CHILD  liveVideo   17
CHILD  Weather   18
CHILD  ChannelPoster   19
CHILD  BottomBar   20
CHILD  ShowBar   21
CHILD  HideBar   22
CHILD  Hint   23
CHILD  Timer   24
CHILD     25
0 Kudos
Level 10

Re: Refresh Grid View

yeah it's a bit buggy! maybe what's happening is since you're replacing the item with itself it ends up doing two removals.  Create a new node fresh and replace the old one, don't try to re-use it like that and I think it will resolve the problem.
newMarkupGrid = CreateObject("roSGNode","myMarkupGrid")
0 Kudos
Level 7

Re: Refresh Grid View

Well joetesta, I think I tried it all with same result. Using the replacechild wants to remove the child preceding the child replaced. No idea why, actually put some dummy children in before it and with each pass of the loop it removed them and kept going up the tree. But after all this I did find a solution which may be helpful to others that may run into the same thing. I am making a copy of the existing child something like
m.newchild= m.oldchild

this copies all existing info from old child. I then set my m.newchild.content to the new content. After this I removechildindex of the oldchild and append the newchild. This puts the newchild at the end of the children. By doing this, it no longer removes any other children in the list. No idea why replacechild doesn't work for me, but this seems to do the job.  Thanks for looking over it with me and giving me ideas.
It does load new content but the grid still doesn't update, not until the event occurs a second time then it updates the grid.
0 Kudos