Skip to Content
0

TreeTable - subitem not displayed

Feb 08, 2017 at 04:43 PM

27

avatar image

Hello,

this is the first time I use the TreeTable and I am not able to display the subitem.

Here is the structure of the data

root.jpg

Here is how I created the data

    	var parent = {};     
    	var parentId = 0; 

    	if (oMessages) {
    	   var oMessageOut;

    	   for (var i = 0; i < oMessages.length; i++) {
    	       var oMessage = oMessages[i];
    	       if(oMessage.Text.substring(0, 5) == '.....'){
	          parent[oMessageOut.id].children.push(oMessage.Text); 
    	           }
    	       else {   	                    	  
        	         oMessageOut = { id: parentId,
		                             text: oMessage.Text,
		                             children: [] };           
	      	         parent[oMessageOut.id] = oMessageOut;	      
	                 parentId++;
    	            }
    	       }
    	   }

// find the root nodes (no parent found) and create the hierarchy tree
// from them
    	var root = [];    	            
    	for (var i in parent) {
	    	var parentkey = 'id' + parent[i].id;
	    	if (!parent[parentkey]) {
	    	   root.push(parent[i]);
	    	}
    	 }    	               	
      this.setProperty("/__SESDetailMessages",root);      


Here is the view

	  var oTable = new sap.ui.table.TreeTable({
	  	columns: [
	  		new sap.ui.table.Column({label: "Text", 
                                            template: "JsonSes>text"}),
	  		new sap.ui.table.Column({label: "Time",
                                         template: "JsonSes>children"})
	  	],
	  	selectionMode: sap.ui.table.SelectionMode.Single,
	  	enableColumnReordering: true,
	  	expandFirstLevel: true,
	  	toggleOpenState: function(oEvent) {
	  	   var iRowIndex = oEvent.getParameter("rowIndex");
	  	   var oRowContext = oEvent.getParameter("rowContext");
	  	   var bExpanded = oEvent.getParameter("expanded");

	  		alert("rowIndex: " + iRowIndex +
	  		" - rowContext: " + oRowContext.getPath() +
	  			 " - expanded? " + bExpanded);
	  	}
	  });


	    oTable.setModel(this.getModel("JsonSes")); 
	    oTable.bindRows({
			path: "JsonSes>/__SESDetailMessages",
			parameters: {
				arrayNames: ['children']
			}
	    });	    


 

I know that I have created 2 columns but it was only to display the information as a test.

I want to have the 'text' as the parent and the 'time' as the children... How do I get it ? How do I get the icon to open or close the items?

time-tree.jpg

Thank you for your help!

Marie

root.jpg (31.7 kB)
time-tree.jpg (32.4 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers