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

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"
m.MyGrid=m.top.findNode("MyGrid")
for i = 0 to m.top.getChildCount()-1
  child = m.top.getChild(i)
  ?"CHILD "child.id"   "i
  if child.id = "MyGrid"  
    ?"MyGrid INDEX  "i
    exit for
  end if
end for

  m.MyGrid.content = m.global.posterx.show
  m.top.replaceChild(m.MyGrid ,i)
  ?"REPLACEMENT  "m.top.replaceChild(m.MyGrid ,i)
m.programmarkupgrid.SetFocus(true)
m.programmarkupgrid.visible= true
?"RESET CONTENT DONE"
for q= 0 to m.top.getChildCount() - 1
?"CHILD  "m.top.getChild(q).id
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
REPLACEMENT  true
in onFocusChanged
PROGRAM COLUMN FOCUSED  0
GRID LOCATION  2
NUMBER OF COLUMNS  20
RESET CONTENT DONE


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

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")
aspiring
0 Kudos
btpoole
Channel Surfer

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