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

Maintaining State issue with Virtual Scrolling

5 Answers 118 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bob
Top achievements
Rank 1
Bob asked on 09 Feb 2015, 06:08 PM
I had previously created a gridstatemanager that stores the state of our grids, including filter, sort, page, etc. 

I based the code on an example that you guys published. http://www.telerik.com/support/code-library/save-grid-state-in-session-on-server-side

We are having a problem in that the "page" is stored in session, and when queried, that page of data is returned, but the grid doesn't realize it is on that page.

I switched the code to use the newly added getOptions/setOptions and the same issue occurs. 

Questions.

1. Is there a way to tell the grid what page of data it is on? There is no way to scroll "up" if not on page one, and also, if we scroll down, the grid just requests page 1.

2. I switched the code to use the getOptions/setOptions. The same paging issue occurs. Also, when I use setOptions, my grids header disappears when I call setOptions. Why would this happen?

3. In your sample originally used, the code is taking any date filers and making parsing the date. I assume this is because the date is stored as a string once you stringify it. Does setOptions automatically take care of this?

4. If your sample your code shows it does a setOptions and the filtered data occurs after pressing the "load options" button. Is this sample using remote data or local data? When I do setOptions no query occurs and I still have to call the datasource.Read(). 


5 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 11 Feb 2015, 02:03 PM
Hello Bob,

I am afraid there is not way to set initial page when when virtual scrolling is enabled. Initial page can only be set when using the regular pager. The virtual scroller is designed to be one directional i.e. you can scroll it and change the dataSource.page but if you change the dataSource.page the scroller won't be scrolled accordingly.

Kind Regards,
Petur Subev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Bob
Top achievements
Rank 1
answered on 11 Feb 2015, 02:46 PM
That's kind of what I thought you would say about the page position.

What about the issue with date parsing and setOptions and the fact that my header disappears?
0
Petur Subev
Telerik team
answered on 13 Feb 2015, 12:13 PM
Hello Bob,

My apologies for the late reply on the other questions:

3) when you use getOptions the filter expressions contain a Date field as value, indeed stringifying them is a problem which you should parse back manually, the setOptions method expects the options of the dataSource to be as they were retrieved through the getOptions method.

4) The following demo uses remote data. If the AutoBind option of the Grid is set to true, then after setting the options of the Grid you should not perform any read request. Please demonstrate your case so we see what is the issue that you struggle with.

Kind Regards,
Petur Subev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Bob
Top achievements
Rank 1
answered on 13 Feb 2015, 03:12 PM
Thanks, do you have an example of "fixing" the dates before setting the options to setOptions? I assume the code is similar to that other sample, the filters are just in a slightly different location in the options objects.

So, that's the difference, we have autobind set to false, because we have code in our common document ready that binds to every grid, checks for settings in sessionStorage, and then calls the dataSource's read(). Good enough.

I still don't know why the header toolbar disappears, I will attempt to create a sample. 

0
Petur Subev
Telerik team
answered on 17 Feb 2015, 09:40 AM
Hello Bob,

We do not have such example that demonstrates the serialization of Date objects. You can search the net for similar questions and create your own serialization format if the default one does not behave as expected. 

Kind Regards,
Petur Subev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Bob
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Bob
Top achievements
Rank 1
Share this question
or