【问题标题】:ExtJS Store - copy specific fields to storeExtJS Store - 复制特定的字段来存储
【发布时间】:2011-09-14 12:47:36
【问题描述】:

我正在使用 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');

但我在浏览器的控制台上得到以下输出: 未捕获的类型错误:无法调用未定义的方法 'get'

有什么建议吗?

提前致谢!

【问题讨论】:

    标签: mysql ruby-on-rails-3 jsonstore extjs3


    【解决方案1】:

    你必须尝试这样的事情:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-21
      • 1970-01-01
      • 2013-07-24
      • 2011-07-02
      • 2011-02-18
      • 2014-08-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多