cancel
Showing results for 
Search instead for 
Did you mean: 

how to access view?

Former Member
0 Kudos

Hello,

I am using fusioncharts in my project. In one of the scenario of drilldown charts I get a call to controller from fusioncharts where I have to show a popup.

I am able to bring up the popup but I get error while executing this.getView().addDependent(oPersonalizationDialog);

Error is because 'this' refers to different context and not able to get the view.

How to access the view in this scenario?

Thanks,

Rashmi

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member213386
Active Participant
0 Kudos

Hi Rashmi,

sometimes when "this" is not what you think, you can still get the "this" you want quite easily

Maybe you have your code line in the view controller, but in a anonymous function, at that moment "this" is different. Still you can pass the outer "this" to the inner anonymous function via

var that = this;

and in your anonymus function just access that.getView()...

(the closure concept)

Or you could bind the context to your function via jQuery.proxy( yourfunction, this).

Then the this in the function is the one you expect,

maybe this helps a bit, Sophie.

Ps: what was the main reason to use Fusion charts?

kedarT
Active Contributor
0 Kudos

Hi Rashmi,

How about using the sap.m.Popover to achieve your requirement.

Look at - SAPUI5 Explored

Hope this helps.

SergioG_TX
Active Contributor
0 Kudos

Rashmi,

the this keyword would have a different context depending if you use it in the view or in the controller in an event. you could access the view by using sap.ui.view(path.to.viewName)

this will solve your issue..

Former Member
0 Kudos

Hi Sergio,

Thanks for the quick reply. I tried sap.ui.view("ui.reporting.view.AnnualSummary"). it's not available. Do you think I am missing something?

~Rashmi

SergioG_TX
Active Contributor
0 Kudos

yes, are you trying to access the view from the controller? or some where else? do you have any code you can share so I can see what may be missing

Former Member
0 Kudos

Yes I am accessing from Controller. I am thinking how to segregate the code & share it.

SergioG_TX
Active Contributor
0 Kudos

sounds like you already added the pop-up control in the view and you are able to open it, right.. what else are you trying to do when you get this error?

Former Member
0 Kudos

yes I am able to open the popup. though I have not added any data. popup is empty.

I have to add the popup to view as dependent to access model binding context.

SergioG_TX
Active Contributor
0 Kudos

why not add the content when creating the pop-up in the view initially?

you can access the sapui5 object from anywhere with sap.ui.getCore().byId(controlId) to perform additional manipulation or the object

Former Member
0 Kudos

thats what I am not able to understand sap.ui.getCore().byId("ui.reporting.view.AnnualSummary") also I get as undefined. as you said, I can add dependent in the beginning but I have to access the OData before bringing up the popup.

SergioG_TX
Active Contributor
0 Kudos

it would be easier if we can see code samples.

Former Member
0 Kudos

Rashmi,

Can you try below way for instantiating view, if not tried before:

Instantiating Views

Methods Controlling the Initial Instantiation

if you are following the first link, have your code like below:


var myView; //declare this at the top (global var)


if(!myView){

//code for view instantiating

}


Thanks, MS