Prometheus
Prometheus

Reputation: 300

refreshing the data in a list and store, sencha touch

I have an itemTapHold event on my list. In this event I make an ajax request like this:

Ext.Ajax.request({

        url: //goes to delete php script,
        method: 'post',
        params:

        {

        userid: userid,
        name: name

        },

        success: function (response) {


            Ext.Msg.alert( name + " is verwijderd");


        },

        failure: function (response) {



        }
});

This bit of code works, the tapped item will be deleted in my database.

The problem is how do i refresh my list/store? I already tried to refresh my list with refresh() which is actually working cause my checkboxes i have in my list will all go unchecked.

I also did a console.log(Selections);(which is the store my list is using) and it will return me the store with data before i deleted my record.

Am i missing something here?

PS. i also don't know where to put the refresh methods in my event? after, before or in my ajax request?

Upvotes: 1

Views: 442

Answers (1)

Jaimie Whiteside
Jaimie Whiteside

Reputation: 1220

There are are a couple of Store methods you can use:

  1. remove( records )
  2. removeAt( index )

In your success function you could call store.remove(<your record>);

Alternatively, you could get the index of the record with the userid then remove it.

var index = store.find('userid', userid);
store.removeAt(index);

The event fired by removing the record from the store will be caught by the grid and it should be updated accordingly.

Upvotes: 1

Related Questions