I am implementing extjs 3.2.1 with rails 3.x. I have a JsonWriter that writes all the fields in the MySQL database through Json store. Is there a way to replicate the records from one Json Store to the other, with some difference of fields.
This is what i tried:
var RecRecordDef = Ext.data.Record.create([
{name: 'product_master_id'},
{name: 'qty'},
{name: 'stock_price'},{name: 'discount_rate'},
{name: 'amount'}
]);
salesbtn.on("click",function(){
for(var cnt=1;cnt<=salestore.getCount();cnt++)
{
var rectmp= salestore.getAt(cnt);
var receiptrec= new RecRecordDef({
product_master_id:rectmp.get('product_master_id'),
qty:rectmp.get('qty'),
stock_price:rectmp.get('stock_price'),
discount_rate:rectmp.get('discount_rate'),
amount:rectmp.get('amount')
});
recstore.add(receiptrec);
}
recstore.save();
});
where, var recstore= Ext.StoreMgr.get('ReceiptStore');
but I am getting the following output on browser's console : Uncaught TypeError: Cannot call method 'get' of undefined
Any suggestions?
Thanks in advance!
You must try something like this:
Ext.each(salesstore.getRange(), function(item, index, all){
var receiptrec= new RecRecordDef({
product_master_id: item.get('product_master_id'),
qty:item.get('qty'),
stock_price:item.get('stock_price'),
discount_rate:item.get('discount_rate'),
amount:item.get('amount')
});
recstore.add(receiptrec);
}, this);
recstore.save();