Skip to Content
avatar image
Former Member

How to build a Hieararchical Table

Hi.

I follow the below link to create a tree structured table.

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/de59f7c2-0401-0010-f08d-8659cef543ce

The document says, the child nodes are rendered only when a parent node is clicked at runtime. Is it possible to show all the parent and child nodes at the same time.

Regards

Bala

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    May 23, 2007 at 01:26 PM

    Bala,

    Yes, this is possible.

    In example for tutorial, add additional parameter isRecursive type=boolean to method addCatalogEntries.

    Then alter method body like below:

    public void addCatalogEntries( com.sap.tut.wd.treetable.wdp
    .IPrivateTreeTableView.ICatalogEntriesNode node,
    java.lang.String parentId, boolean isRecursive )
    {
      //@@begin addCatalogEntries()
      IPrivateTreeTableView.ICatalogEntriesElement newCatalogEntriesElement;
      for (int i = 0; i < Catalog.getLength(); i++) {
        if (parentId.equals(Catalog.getParentId(i))) {
          // create new context node element
          newCatalogEntriesElement = node.createCatalogEntriesElement();
          node.addElement(newCatalogEntriesElement);
          // provide node elements with data
          newCatalogEntriesElement.setID(Catalog.getCATALOGID(i));
          newCatalogEntriesElement.setTITLE(Catalog.getTITLE(i));
          newCatalogEntriesElement.setDESCRIPTION(Catalog.getDESCRIPTION(i));
          newCatalogEntriesElement.setAMOUNT(Catalog.getAMOUNT(i));
          if ("ARTICLE".equals(Catalog.getCATALOGTYPE(i))) {
            // checkbox is visible by default
            newCatalogEntriesElement.setPUBLISHED(Catalog.getPUBLISHED(i));
            // third level is last level
            newCatalogEntriesElement.setIsLeaf(true);
          } else {
            // a CATEGORY or ARTICLEGROUP does not use the checkbox column
            newCatalogEntriesElement.setUsageOfPublishedAttribute(
    WDVisibility.BLANK);
            newCatalogEntriesElement.setIsLeaf(false);
          }
    
          /* ADDED CODE */
         if (isRecursive) {
           addCatalogEntries(
             newCatalogEntriesElement.nodeChildCatalogEntries(), 
             newCatalogEntriesElement.getID(), true
           );
           newCatalogEntriesElement.setChildrenLoaded(true);
           // THIS EXPAND ITEM ON UI
           newCatalogEntriesElement.setExpanded(true);
         } 
      }
    }
    //@@end
    }
    

    Now you can invoke

    addCatalogEntries(wdContext.nodeCatalogEntries(), "ROOT", true);

    in wdDoInit and you are done.

    Valery Silaev

    SaM Solutions

    http://www.sam-solutions.net

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Valery.

      Thanks for the reply, It was useful. But I have a different scenario.

      My issue on using tree structured table is:

      The Database structure is:

      MaterialTemplate - contains list of all material templates. It has reference to MaterialMD

      MaterialMD - contains all newly created materials

      MaterialValue - Contains the materials with markups and prices. It has reference to MaterialMD

      MaterialGroup - which contains other details with Materialtemplatereference.

      Now I have two scenarions:

      1. Create a new Materialgroup.

      While creating a new material group, I will select one material template which shows

      the list of materials in it (which is in hierarchical structure). From RFC it takes the cost for each material . Then I need to give some

      markup vaue and do some calculation, and finally while saving it saves all materialinformation to MaterialGroup table and cost, markup, materialMD information into

      MaterialValue table.

      Now I come back to main dashboard.

      2. View Materialgroup details

      When I click a materialgroup, now it shows the details of it.

      Also it has to show the information for this mateial group and bucketMD details in the table .

      When I come to the table structure I have to show the information taking from MaterialValue table, where all the data has been saved finally.

      My Question here is: While creating the material group, the information that has to be shown in the table has to come from one table(Material Template)

      and while showing the material group details it has to show the information from MaterialValue table.

      If I use the example as it is in above document Can I implement this scenario because the information is coming from two tables in each scenario.

      My only concern is when I click the parent object in the tree structured node, its information will differ depends upon from where to get it.

      Can I use the existing document to continue this process.Or Could you provide me some tips how to proceed this.

      Many Thanks

      Bala