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

How do you clear and reset an Endless Scrolling ListView?

1 Answer 638 Views
ListView (Mobile)
This is a migrated thread and some comments may be shown as answers.
Derrick
Top achievements
Rank 1
Derrick asked on 18 Dec 2013, 02:47 PM
I am implementing an Endless Scrolling list view.  I would like to persist the list data items and position when I navigate to a detail view and return.  This works.  I would also like to be able to completely reset the Endless Scrolling list view when I go back to the main app view and return to the Endless Scrolling ListView, just like I had set the Endless Scrolling view itself to data-reload="true".  This is not working for me.

I can reset and clear a normal ListView like this;

contactListSource = new kendo.data.DataSource.create({data:[]});
$("#contacts_list_search_results").kendoMobileListView({
dataSource: contactListSource,
template: $("#contact_list_item_template").html()
});


The paging functionality complicates the clear with the Endless Scrolling list and causes issues when I try to reset the ListView.  The next time I come back to the Endless Scrool List the display starts in the middle of the list, and the first records from the list often don't get displayed. This is what I have so far to clear and rest (it only works if I have not scrolled on the original list, so I believe the issue has to do with a persisted scroll position):

                    $(".km-scroll-container").css("-webkit-transform", "");
                    $("#contacts_list_search_results").data("kendoMobileListView").dataSource.data([]);
                    $("#contacts_list_search_results").data("kendoMobileListView").dataSource._page=1;
                    $("#contacts_list_search_results").data("kendoMobileListView").dataSource._skip=0;

How is it possible to completely clear and reset and Endless Scrolling list view?

Thanks,
Derrick

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 20 Dec 2013, 10:09 AM
Hello Derrick,

If you want to reset the widget you should read the first page of its dataSource and reset its scroller. For example:
var listview = $("#endless-scrolling").data("kendoMobileListView");
listview.dataSource.page(0); //request the first page
listview.scroller().reset(); //reset the scroller

In case you want to clear the DataSource (e.g. no information to be displayed) you should create a new DataSource instance and set it through the setDataSource method.
The scroller have to be reset too.

Regards,
Alexander Valchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
ListView (Mobile)
Asked by
Derrick
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or