PDA

View Full Version : Not able to delete records from buffered store.



Simi Thomas
18 Nov 2013, 9:54 PM
Not able to delete record from buffered store, gettign the error 'removeAt operation not suppported from buffered Store'

Gary Schlosberg
21 Nov 2013, 2:37 PM
It is saying that it is not supported because that is indeed the case. The buffered store doesn't support adding, deleting or editing records. It is intended to address performance in read-only scenarios. Would a buffered renderer (http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.grid.plugin.BufferedRenderer) help?

agunescu
5 Mar 2014, 6:37 AM
Is this working in ExtJS 4.2.2 version?

Gary Schlosberg
5 Mar 2014, 2:28 PM
No, I'm afraid not. My understanding is that the buffered store is best used to display large datasets without offering add/delete capabilities.

muilas
16 Jul 2015, 10:27 PM
Sorry, but I'm disagree. In my case, I have about 20000 records and user make an order, i.e., edit one quantity field in the buffered store. And it will be very comfortable to make it from the one grid without additional forms.

Here my litle code for edditing in the BufferedStore ExtJS 5.1.1.451



Ext.define('Ext.overrides.data.BufferedStore', {
override: 'Ext.data.BufferedStore',

afterEdit: function(record, modifiedFieldNames) {
var me = this;
if(this.autoSync) {
me.proxy.batch(Ext.apply({}, {
operations: {
update: me.getUpdatedRecords()
},
listeners: me.getBatchListeners()
}));
}
},

methodRecords: function( comparator, method ){
var items = this.getData().getValues();
for (i = 0, length = items.length; i < length; i++) {
for (j = 0, length2 = items[i].length; j < length2; j++) {
if (comparator.call(this, items[i][j])) {
method(items[i][j]);
}
}
}
},

getUpdatedRecords: function() {

var items = this.getData().getValues(),
ret = new Ext.util.Collection(),
scope = this,
fn = function(item) {
return item.dirty === true && item.phantom !== true && item.isValid();
};
this.methodRecords(fn, function(item){ ret.add(item); });
return ret.getRange();
},


afterCommit: function(record, modifiedFieldNames) {
var me = this;
if (!modifiedFieldNames) {
modifiedFieldNames = null;
}
me.fireEvent('update', me, record, Ext.data.Model.COMMIT, modifiedFieldNames);
},

getRemovedRecords: function() {
return this.removed || [];
}
});

Gary Schlosberg
17 Jul 2015, 3:05 PM
Thank you for sharing with the community. I was just going by what one of our developers stated.
https://www.sencha.com/forum/showthread.php?269839#4

Aren't there issues if the record to be deleted is no longer available?

AntaresKManuel
20 Feb 2017, 3:14 PM
I'm a bit late to this thread, but in case anyone else runs across this issue, here's a simple solution. (Tested to work from 4.0.0 -> 6.2.0)


In my controller I have this function:


onRemoveClick: function (view, recIndex, cellIndex, item, e, record) {
view.getStore().getProxy().batch({ destroy: [record] });
view.getStore().load();
}



which is fired from this actioncolumn on the grid:

{
xtype : 'actioncolumn',
width: 30,
sortable: false,
menuDisabled : true,
items: [{
iconCls: 'fa fa-remove',
tooltip: 'Delete',
handler: 'onRemoveClick'
}]
}



And my store:


Ext.define('Website.store.pricing.InvoiceStore', {
extend: 'Ext.data.BufferedStore',
model: 'Website.model.pricing.InvoiceModel',
autoLoad: true,
remoteSort: true,
remoteGroup: true,
proxy: {
type: 'rest',
url: '/api/pricing/Invoice',
reader: {
rootProperty: 'data.data',
type: 'json',
totalProperty: 'data.totalRows'
}
}
});