cancel
Showing results for 
Search instead for 
Did you mean: 

When Tree table opens first time expandToLevel() not working

Viswanath
Participant
0 Kudos

Hi All,

I have a button, when I click on it I am opening a fragment which is having tree table shown in Dialog . Here issue is I am using

var oTable = sap.ui.getCore().byId("treeTable");
		oTable.expandToLevel(2);

when fragment is opening for first for first time expandToLevel() is not applying. when I closed the Dialog and open again expandToLevel() is working. Below is my fragment code.

	onEdit:function(){
		
		var sService = "/sap/opu/odata/sap/ZEntity_SRV/" ;
		var oModel = new sap.ui.model.odata.v2.ODataModel(sService , {useBatch : false });	
		if (! this._oDialog) {
		      this._oDialog = sap.ui.xmlfragment("crm.fragmenTreeSelect", this);
		    } 
		
		this.getView().addDependent(this._oDialog);
		this._oDialog.setModel((oModel),"TreeselectTable" );
		this._oDialog.setContentWidth("480px");
		this._oDialog.open();
		var oTable = sap.ui.getCore().byId("treeTable");
		oTable.expandToLevel(2);
	
	},
	

Could anyone please help here how to apply expandToLevel() first time of opening table.

Thanks,

Best Regards,

Viswanath

Accepted Solutions (1)

Accepted Solutions (1)

Viswanath
Participant
0 Kudos

Hi,

I found the issue, I want to share so it will be useful to others.

When I check my network tab service status is pending means before data is fetched below code is executing so for first time I am unable to expand

 var oTable = sap.ui.getCore().byId("treeTable");
		oTable.expandToLevel(2);

So I have to implement this code once I got data from service to table so I added below code and now it's working fine

oModel.attachRequestCompleted(function(oEvent){
			var oTable = sap.ui.getCore().byId("treeTable");
			oTable.expandToLevel(2);
			
		});

Answers (0)