ExtJS Store/Grid reset

11,216

Solution 1

It will be useful to see some code examples (and extjs version), but you can simply use loadRecords method (http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.JsonStore-method-loadRecords):

grid.store.loadRecords([array of your new records here], {addRecords: false});

{addRecords: false} indicates that existing records will be removed first.

Solution 2

for ExtJs4: simply doe store.loadRecords([ array ]). In version 4.2.2 the store.proxy has NO clear() method so that doesn't work (was proposed in other examples elsewhere...)

If you want to to totally clear store and proxy, pass an empty array. This is handy because in some cases you want to clear the store and removeAll only moves the data to an array managed internally in the store so when later doing a sync on a gridStore which shows only 1 record, you may see your controller flooded with a bunch of records marked for removal!!

Share:
11,216
gberg927
Author by

gberg927

Updated on June 04, 2022

Comments

  • gberg927
    gberg927 almost 2 years

    I have a button that when clicked, will create a JSONstore using a url provided. The store is then loaded into a grid. If the button is clicked again, it adds all the information again (so it is listed twice). I want it so that when the user clicks the button, it clears the store/grid and then adds everything.

    Any ideas on how to accomplish this?

    Thanks,

    EDIT ExtJS 3

    datasetStore.removeAll();
    datasetStore.loadData(datasetsArray);