Manually remove a record by its ID. - Ext JS

Greetings,

I have to manually remove records by ID. I failed to find such a method in the default implementation. Thus, to accomplish this I had to subclass Ext.data.Store and introduce a new method called removeId. Here is the code:

myNS.Store = function (config)
{
    myNS.Store.superclass.constructor.call(this, config);
}

Ext.extend(myNS.Store, Ext.data.Store, {

    removeId: function (id)
    {
        var index = this.indexOfId(id);
        this.data.removeAt(index);
        this.fireEvent('remove', this, null, index);
    }
});
I wonder if I'm missing something and there is a simpler way of manually removing records by ID.
  # 2  
03-12-2007, 04:02 AM

Simpler than 3 lines of code? What do you want from it.. mind reading software :?:
  # 3  
03-12-2007, 04:17 AM

No, this way is ok for. I just meant probably there is similar method in the default implementation and I don't have to subclass it.
  # 4  
03-13-2007, 01:03 AM

Did you try:

store.remove(store.getById(id));
  # 5  
03-13-2007, 01:14 AM

Indeed, this seems to be what I need. I'll give it a try.

你可能感兴趣的:(ext)