How to copy records from a store and send them by Ajax.

There are many ways of doing this, here is one in ExtJs by Sencha.


function copyStoreData(store) {
var data = store.getRange();
var len = data.length;
var newData = [];

for(i = 0; i < len; i++) {
newData.push(data[i].data);
}

return newData;
}

if you need to appy a filter just do like this, or even in json.


function copyStoreData(store, filter) {
var data = store.getRange();
var len = data.length;
var newData = [];

for(i = 0; i < len; i++) {
if(data[i].get('field') !== filter) {
newData.push(data[i].data);
}
}

return Ext.encode(newData);
}

Advertisements

One thought on “How to copy records from a store and send them by Ajax.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s