Manually remove a record by its ID. - Ext JS

作者需要手动从Ext.data.Store中按ID删除记录,在默认实现中未找到相应方法,通过子类化Store并添加removeId方法来实现。讨论中提出了使用store.getById结合store.remove的方法作为替代方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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.
Reply With Quote
  #2  
Old 03-12-2007, 04:02 AM
Default

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

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.
Reply With Quote
  #4  
Old 03-13-2007, 01:03 AM
Default

Did you try:

store.remove(store.getById(id));
Reply With Quote
  #5  
Old 03-13-2007, 01:14 AM
Default

Indeed, this seems to be what I need. I'll give it a try.
Reply With Quote
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值