Adding Rows
You may have noticed while we were looking at the code that allows for editing, that there were some variables that mentioned add
so let's take a look at that next.
In the demo app, we only allow you to add children to Department rows. We could add rows to any SmartNgRX row, but we've kept the demo simple.
We kick off the add process in our addChild()
specifying the current node and the type of child we want to add. Your code may only need to pass the current node. This will always be the parent of the new row.
Since this is a new row, we set the editingContent
field to a default string that the end user can edit. More work is done in our tree.component.ts
file is to keep track of what we are doing in the view so that repaints don't disrupt the user's experience.
All the child arrays in SmartNgRX are of type
. We've addToStore()
, getIdAtIndex()
, and removeFromStore()
methods.
Similar to the edit process, ESC
calls cancelEdit()
and ENTER
calls saveNode()
. cancelEdit()
just sets things back to the way they were