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:
I wonder if I'm missing something and there is a simpler way of manually removing records by ID.
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);
}
});

|
#2
|
|
Simpler than 3 lines of code? What do you want from it.. mind reading software :?:
![]() |
|
#3
|
|
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
|
|
Did you try:
store.remove(store.getById(id)); ![]() |
|
#5
|
|
Indeed, this seems to be what I need. I'll give it a try.
![]() |
作者需要手动从Ext.data.Store中按ID删除记录,在默认实现中未找到相应方法,通过子类化Store并添加removeId方法来实现。讨论中提出了使用store.getById结合store.remove的方法作为替代方案。
1万+

被折叠的 条评论
为什么被折叠?



