Search code examples
rokubrightscriptrowlist

Dynamically update RowList with new item at index 0


I'm filling a RowList that's a child of a Grid Screen. The rowlist is filled at start-up. Later, after user interaction, I need to add to the rowlist. In particular, I need to add a new row in index 0 (new first row) shifting all rows down. I'm able to add the new row item (as I see the poster that's embedded in the item), however, the row title does not show. I've stepped through the code and nothing seems wrong yet the row title does not show for the newly added row.

I've tried several variations of the following code, but, I can't get the 'new' row's title to show.

                    ' Create a parent node for the RowList.   
                    parentRowlistNode = CreateObject("roSGNode", "ContentNode")
                    
                    continueNode = CreateObject("roSGNode", "ContentNode")
                    continueNode.addFields( { "order": "most_recent", "TITLE": "Some new row" } )
                    continueNode.AppendChild(feedItem)
                    newgridChildren = []

                    ' Update the RowList with the newly added row.
                    rowList = gridScreen.FindNode("rowList")

                    'newgridChildren.Push(continueNode)
                    for each gridChild in gridChildren
                        newgridChildren.Push(gridChild)
                    end for
                    newgridChildren.Push(continueNode)
                    
                    'rowList.content.Update({
                    '    children: newgridChildren                                
                    '}, true)

                    parentRowlistNode.Update({
                        children: newgridChildren
                    }, true)
                    
                    gridScreen.content = parentRowlistNode

Solution

  • I was able to resolve this issue by changing the following:

    continueNode.addFields( { "order": "most_recent", "TITLE": "Some new row" } )
    

    to

    continueNode.Update( { "order": "most_recent", "TITLE": "Some new row" }, true )