Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Delete item in store doesn't refresh Grid

  1. #1
    Sencha Premium Member
    Join Date
    Jun 2015
    Posts
    33
    Answers
    1

    Question Answered: Delete item in store doesn't refresh Grid

    Hi,

    I'm using Ext JS 5.1.1

    Upon deleting item from store, the grid view is not refreshed.

    Code:
    grid.store.remove(grid.getSelection());

    Thanks,
    Senthur

  2. Quote Originally Posted by srajakumar View Post
    I have tried calling sync

    Code:
    grid.store.remove(grid.getSelection());
    grid.store.sync();
    Calling sync() will make the DELETE request to the server for the removed records. You can add a callback and handle the reload:

    Code:
    grid.getStore().sync({
       callback: function(batch, opts) {
           grid.getStore().reload();
       }
    });

  3. #2
    Sencha User joel.watson's Avatar
    Join Date
    Nov 2014
    Posts
    3,120
    Answers
    446

    Default

    Hi--

    It seems to work okay for me:



    Can you share a test case of the issue you're seeing?

    Thanks
    Joel

  4. #3
    Sencha Premium Member
    Join Date
    Jun 2015
    Posts
    33
    Answers
    1

    Arrow Remote grid :)

    My mistake. My question was not clear.

    I am using a remote grid. Ie., a rest proxy on store to retrieve data with a page size of 25 items per page.

    When I remove an item using the API, item gets removed from the grid. But the grid is not refreshed to bring in the next item using the rest call.

    Ie., when I remove 2 items from the grid, it shows only 23 items, where I have a lot of other items in database.

    Hope I explained a bit clear.

    Thanks!

  5. #4
    Sencha User joel.watson's Avatar
    Join Date
    Nov 2014
    Posts
    3,120
    Answers
    446

    Default

    Hi--

    Can you just reload the page after getting the success response back from the delete call?

    Thanks
    Joel

  6. #5
    Sencha Premium Member
    Join Date
    Jun 2015
    Posts
    33
    Answers
    1

    Default

    you mean reload grid?

    Quote Originally Posted by joel.watson View Post
    Hi--

    Can you just reload the page after getting the success response back from the delete call?

    Thanks
    Joel

  7. #6
    Sencha User joel.watson's Avatar
    Join Date
    Nov 2014
    Posts
    3,120
    Answers
    446

    Default

    Quote Originally Posted by srajakumar View Post
    you mean reload grid?
    Sorry, by "page" I meant the loaded page in the grid's store. If you call reload() on the store, it should retrieve a refreshed set of data for the current page in the data set.

    Thanks
    Joel

  8. #7
    Sencha Premium Member
    Join Date
    Jun 2015
    Posts
    33
    Answers
    1

    Default

    I have tried calling sync

    Code:
    grid.store.remove(grid.getSelection());
    grid.store.sync();
    Quote Originally Posted by joel.watson View Post
    Sorry, by "page" I meant the loaded page in the grid's store. If you call reload() on the store, it should retrieve a refreshed set of data for the current page in the data set.

    Thanks
    Joel

  9. #8
    Sencha Premium Member
    Join Date
    Jun 2015
    Posts
    33
    Answers
    1

    Default

    Looks like reload is different.

    Can you tell me how to call delete then reload. Like a callback method for remove?

    Code:
    grid.store.remove(grid.getSelection());
    grid.store.reload();
    Quote Originally Posted by joel.watson View Post
    Sorry, by "page" I meant the loaded page in the grid's store. If you call reload() on the store, it should retrieve a refreshed set of data for the current page in the data set.

    Thanks
    Joel

  10. #9
    Sencha User joel.watson's Avatar
    Join Date
    Nov 2014
    Posts
    3,120
    Answers
    446

    Default

    Quote Originally Posted by srajakumar View Post
    I have tried calling sync

    Code:
    grid.store.remove(grid.getSelection());
    grid.store.sync();
    Calling sync() will make the DELETE request to the server for the removed records. You can add a callback and handle the reload:

    Code:
    grid.getStore().sync({
       callback: function(batch, opts) {
           grid.getStore().reload();
       }
    });

  11. #10
    Sencha Premium Member
    Join Date
    Jun 2015
    Posts
    33
    Answers
    1

    Default

    Thanks.

    Just 1 question.

    Even when my store is in autoSync=false mode, store.remove removes item from database without store.sync call.

    Do we really need a sync?

    Quote Originally Posted by joel.watson View Post
    Calling sync() will make the DELETE request to the server for the removed records. You can add a callback and handle the reload:

    Code:
    grid.getStore().sync({
       callback: function(batch, opts) {
           grid.getStore().reload();
       }
    });

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 1
    Last Post: 2 Oct 2013, 6:39 AM
  2. [MOVED] Please Implement Delete Key to delete items in addition to Delete Menu Item
    By markjlyon in forum Ext Designer: Help & Discussion
    Replies: 1
    Last Post: 11 May 2010, 7:48 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •