Clear all records from a store
Asked Answered
B

4

6

I have a store, I am loading records from it successfully. Now i need to clear all the records in it. How can i do this ?

myStore.remove(); // DID NOT WORK
myStore.clear(); // ENDED UP WITH AN ERROR TypeError: myStore.clear is not a function

How could i solve this?

Bathhouse answered 29/7, 2012 at 7:52 Comment(0)
B
6

myStore.loadData([],false); is the solution.

Bathhouse answered 29/7, 2012 at 7:57 Comment(1)
No, it isn't. You are loading a "empty" data and suppressing the event. You must use "myStore.removeAll()"Fabric
C
10

Remove will remove the records you pass in. You want removeAll as in myStore.removeAll();

Clorindaclorinde answered 30/7, 2012 at 11:50 Comment(0)
M
10

I find out that, at least on ExtJS 4.2.3, removeAll give an error the first time it is issued after a load. I got it resolved by doing:

store.clearData();
store.removeAll();
Monopolize answered 29/5, 2015 at 18:1 Comment(0)
B
6

myStore.loadData([],false); is the solution.

Bathhouse answered 29/7, 2012 at 7:57 Comment(1)
No, it isn't. You are loading a "empty" data and suppressing the event. You must use "myStore.removeAll()"Fabric
C
0

I'm using version 2.0.12 and none of the above solutions worked. I read their readme.md and found store.clearAll();. That was my solution.

Chiropodist answered 1/4, 2020 at 18:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.