cancel
Showing results for 
Search instead for 
Did you mean: 

How to show the views one by one with some Time interval in SAPUi5?

former_member184238
Participant
0 Kudos

Hi,

In my Application I have so many views. In each view we have one chart.

No I want to display these charts one by one with Some time Interval without clicking any button. i.e Navigating from one view to another with some time Interval.

My Project Structure is like below.

I have written the below code in index.html to get the view data one by one .

<script>

  sap.ui.localResources("navigation_chart");

     var app = new sap.m.App({initialPage:"idchart11"});

     var id = setInterval(navigation, 3000);

       var i=1;

 

   function navigation(){

     var page = sap.ui.view({id:"idchart1"+i, viewName:"navigation_chart.chart"+i, type:sap.ui.core.mvc.ViewType.JS});

     app.addPage(page);

console.log(page);

     app.placeAt("content", "only");

       i++;

             if(i > 2){

                clearInterval(id);

                } 

      }

</script>

But my problem is in console I am getting views one by one .

But I can show only First chart. Even it goes to the second view (In console I can see the Second view also) it doesn't show the second chart.

It is always showing the first chart.

How to remove first view and add the second view to display charts one by one?

Please help me.

Thanks&Regards

Sridevi

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Sridevi,

Based on the code you have supplied, you are adding the pages to the application but you are not "navigating" to the new page. So you have set the initial page, now you need to navigate to the newly added page.

Try making use of the to function:


app.to(page);

Just give that a try in your algorithm, I have not tested it with your code.

I hope it works.

Kind regards

Miki von Ketelhodt

Answers (1)

Answers (1)

surendra_pamidi
Contributor
0 Kudos

Hi Sridevi,

You are creating with same name i.e. 'page' in one function.

Try to create all pages outside the function with different names and add that pages inside navigate fuction.

Create 'n'number of charts outside the function and add that page inside navigate().

And you can use "app.to(page);"to change the page in app.

Regards,

Surendra.

former_member184238
Participant
0 Kudos

Thank you very much for your reply.

I got it.

Thanks&Regards

Sridevi

jmoors
Active Contributor
0 Kudos

Is there any reason for not using the sap.m.Carousel control? It provides the interval looping out of the box, a visual indicator to show the current position in the list, and the ability for the user to swipe through the views,

Regards,

Jason

former_member184238
Participant
0 Kudos

Hi,

It's really a good Idea. I tried that one. But I was failed to get the views dynamically by using this one.

I am in confusion where we have to write the code to get all views and add these views to the Carousel.

If you have any idea Please suggest me.

I will try in that way also.

Thanks&Regards

Sridevi