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

Programatically delete all items clientside

1 Answer 207 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 10 Mar 2015, 03:32 AM
I've got an all client-side RadListView that I've populated via appendData(items), and add more items via appendData(items) when the user scrolls.

So, this seems like a simple question to me, but I'm unable to figure out how do I remove all the items from the RadListView and populate it again from scratch?  I need to do this when the user changes various search filters on the page.

Appending data, and Prepending data works fine - setting the datasource to an empty list and binding or rebinding seem to have no effect.  (Remember this is all client-side and I don't want any post-backs).

Do I need to destroy and re-create the RadListView itself?

Thanks,
Mike

1 Answer, 1 is accepted

Sort by
0
Angel Petrov
Telerik team
answered on 12 Mar 2015, 02:58 PM
Hi Mike,

You should be able to clear all the items be executing the following code.

JavaScript:
var listView=$telerik.findControl(document,'RadListView1');
listView.set_dataSource([]);
listView.dataBind();
The above JavaScript will set an empty array as a data source this clearing the records from the control.

Regards,
Angel Petrov
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
ListView
Asked by
Mike
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Share this question
or