cancel
Showing results for 
Search instead for 
Did you mean: 

Reg: Navigation Between One View to Another View

former_member227911
Participant
0 Kudos

Hi,

I have created a Two Views and also i have created a Two Buttons. And i wrote the Logic for the Button Event Handler in the First View Controller and also in the Second View Controller. But when i try to execute am getting the following Error.

Uncaught TypeError: Cannot read property '0' of undefined

Below the Code:

In the First View:

// Create A Another Button to go to Next View

  var button1 = new sap.ui.commons.Button({ text : "Go to View1" ,

     press : oController.nextfun });

  var arrayfun = [];

  arrayfun.push(form);

  arrayfun.push(radiobutton);

  arrayfun.push(buttono);

  arrayfun.push(button1);

  return arrayfun;

First View Controller :

next : function()

  {

  var panelref = sap.ui.getCore( ).byId("mypanel");

  var view2ref = sap.ui.getCore( ).byId("idSecond2");

  panelref.removeAllContent( );

  panelref.addContent(view2ref);

  }

In the Second View:

var buttono = new sap.ui.commons.Button({ text : "Back to View1" ,

   press : oController.backfun });

  var array = [];

  array.push(textview);

  array.push(fname);

  array.push(lname);

  array.push(buttono);

  return array;

  }

Second View Controller:

backfun : function()

  {

  var panelref = sap.ui.getCore( ).byId("mypanel");

  var view1ref = sap.ui.getCore( ).byId("idFirstView1");

  panelref.removeAllContent( );

  panelref.addContent(view1ref);

  }

Kindly Help ....

Regards,

Sadiq K

Accepted Solutions (0)

Answers (1)

Answers (1)

SergioG_TX
Active Contributor
0 Kudos

first thing i see is your button function doesnt match the name of the function in the controller..

also, check out the official documentation for the routing and navigation -

https://sapui5.netweaver.ondemand.com/#docs/guide/e5200ee755f344c8aef8efcbab3308fb.html