Skip to Content
0

When Tree table opens first time expandToLevel() not working

Feb 08, 2017 at 04:32 PM

85

avatar image
Former Member

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
avatar image
Former Member Feb 09, 2017 at 10:30 AM
0

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);
			
		});
Share
10 |10000 characters needed characters left characters exceeded