Question

I am working on this ExtJS 4 app, where I have a part to Manage app users.

The form pops up like a window floating: true.

var user_grid_form = Ext.create('Ext.form.Panel',
{
    xtype       : 'form-grid',
    frame       : true,
    title       : 'User Information',
    floating    : true,
    draggable   : true,
    closable    : true,
    closeAction : 'hide',
    bodyPadding : 5,
    layout      : 'column',
    closeAction : 'destroy',
    width       : 532,
    items       : 
    [
        user_grid,
        user_textfield
    ],
    buttons :
    [
       {
            text    : 'Save Edits',
            icon    : 'images/save.png',
            handler : handleUpdates
       },
       {
            text    : 'Delete User',
            icon    : 'images/delete.png',
            handler : handleDeletes
       }
    ]
}).show();  

The user_grid is the grid in my window panel that shows usernames

Now, the issue is that when I select a username, just like jhony and press Delete User my handleDeletes updates the database via Ajax. But then I try to refresh the user_grid and it will not work. After the deletion, the user should disappear from user_grid

This is what I have tried to do inside the handleDeletes:

user_store.splice(ind, 1);      // I removed `jhony` from `user_store` 
                                // which is the `store` for `user_grid`             
user_grid.getView().refresh();  // Now trying to refresh and NO ERRORS NO ACTIONS

Thanks for any clues.

Was it helpful?

Solution

Actually, what you want to do is:

user_grid.getStore().remove(yourRecord); //remove record from the store and also from the grid view
user_grid.getStore().sync(); //send changes to the server

OTHER TIPS

Instead of

user_grid.getView().refresh(); 

try

user_grid.store.load();

and no need to do anything else(splice) on the store if deletion is performed server side.

Thanks for your answer dbrin but it did not work.

I figured that there is no need to touch user_grid grid panel. I just needed to update it's store. The store had data and once I did this, everything worked:

user_store.splice(ind, 1);  
u_store.load(user_store);
// u_store is the store that has user_store data
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top