This is a migrated thread and some comments may be shown as answers.

SPA sample

4 Answers 98 Views
View
This is a migrated thread and some comments may be shown as answers.
Sagi
Top achievements
Rank 1
Sagi asked on 24 Dec 2015, 07:28 AM

Hello,

I was looking today at the blog post http://www.telerik.com/blogs/please-respect-the-back-button

when running the sample http://jsbin.com/OHemASes/3 i was able to see that pressing back button after navigating to the "Orders" links works as expected when 

moving between pages.

However, after moving to a specific page I have copied the url (http://output.jsbin.com/OHemASes/3#/orders/5) and paste it to a new browser instance.

The router did direct the app to Orders view but the selected page was 1.

Shouldn't page 5 supposed to be selected in this scenario ?

thx

Sagi

 

4 Answers, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 25 Dec 2015, 11:26 AM

Hello Sagi,

See the adjusted snippet. The paging should happen after the grid is rendered, and the auto-binding should be omitted. This also eliminates some lines of code that check if the paging should be performed.

Regards,
Alex Gyoshev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Sagi
Top achievements
Rank 1
answered on 25 Dec 2015, 12:38 PM

The snippet does work, thx..

However , I still do not understand one thing in the original implementation (that does not work)  :

The following lines :

if (dataSource.page() != page) {
dataSource.page(page);
}

 

which suppose to move the grid to the correct page :are placed after the line which which suppose to render the grid :

 layout.showIn('#content', views.orders);

I can also see that  views.orders.element property is already initialized before dataSource.page(page); is executed.

Can you please explain why doesn't it work ?

Thx

Sagi

 

0
Sagi
Top achievements
Rank 1
answered on 25 Dec 2015, 01:06 PM

Does the grid is rendered sync ? 

If so is this kendo code which perform this in async way or browser optimizations (e.g. first , execute all method command and only than move to DOM rendering)

When using the calling dataSource.page(page); inside setTimeout (just for testing) , the code does work when hitting the url in a different browser (I guess that the grid was able to render during this time...)

 

thx

 

0
Alex Gyoshev
Telerik team
answered on 25 Dec 2015, 02:43 PM

Hello Sagi,

The problem with the previous example was that the dataSource.page call was executed when the dataSource was already making a request, thus it gets dropped. The workaround is to set autoBind: false on the DataSource and use the query method, which correctly loads the page.

Regards,
Alex Gyoshev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
View
Asked by
Sagi
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Sagi
Top achievements
Rank 1
Share this question
or