Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Does TreeGrid support a UI Mechanism to add a new node, or delete an existing one?

    With the https://www.smartclient.com/smartgwt...ured_tree_grid as example, one can edit column data and nicely drag/change the order of the rows/nodes. I'm not seeing the UI mechanism to add a new row/node into the Tree, or delete one. Does such a UI mechanism exist? Posts from 2007-2010 talk about issues adding new data programmatically ... I'm wondering if there now is a user interface built in to add and/or delete a node/row entry. If not, can you please advise a common (substitute) UI format for how this is done?

    Thanks

    #2
    You can use the built-in setCanRemoveRecords(true) to have a delete icon column. There is no built-in UI for adding records because there are so many ways developers want to offer the feature. You could add a context menu, a toolstrip outside the grid, buttons in a column (like the delete), buttons in a rollover, or any number of other choices.

    Comment


      #3
      Thanks for your reply. If I offered perhaps the simplest solution, like an "add below" icon column, what methods would I call? Are you able to by chance show me a little snippet? I'm new and it would be greatly appreciated.

      Comment


        #4
        Assuming a data-bound TreeGrid, just add a client field of type icon and set the field.icon as desired (add below icon). This will show the icon in all rows for your button. Add a recordClick handler to your field which is called when a user clicks on your icon. In the handler create a new TreeNode with desired default values including parentID value as derived from the clicked record so the new node will show were desired. Call grid.addData() and in the callback find your new node in the tree and call grid.startEditing() with correct rowNum.

        That should get you going but be sure to read the docs on TreeDataBinding first. If you instead want a tree structure that is not data bound and want to add nodes in very specific locations see the docs on TreeGrid.startEditingNew() which isn't applicable for a TreeGrid but gives another method of adding nodes to the tree.

        Good luck.

        Comment

        Working...
        X