1

我正在使用 rails 3.x 实现 extjs 3.2.1。我有一个 JsonWriter,它通过 Json 存储写入 MySQL 数据库中的所有字段。有没有办法将记录从一个 Json Store 复制到另一个,但字段有所不同。

这是我尝试过的:

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();

            });

在哪里,var recstore= Ext.StoreMgr.get('ReceiptStore');

但我在浏览器的控制台上得到以下输出: Uncaught TypeError: Cannot call method 'get' of undefined

有什么建议么?

提前致谢!

4

1 回答 1

2

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();
于 2011-06-15T08:03:47.537 回答