Moving Records between Stores

January 5th, 2009
  • Adding a Record to a Store calls the Record's join method, but that could mean a Record being a member of two Stores (even though it's own internal store property is the last one added to)

    I'm using DnD between Views (I'll post an Ext.ux.DDView soon), and the dragData is an Array of Records. This is going to be a super-useful DnD pattern - dragging between Views.

    Anyway, shouldn't


    join : function(store){
    this.store = store;
    }


    be


    join : function(store){
    if (this.store) {
    this.store.remove(this);
    }
    this.store = store;
    }


    ?


  • Here's what I added:

    /**
    * Creates a copy of this record.
    * @param {String} newId (optional) A new record id if you don't want to use this record's id
    * @return {Record}
    */
    copy : function(newId) {
    return new this.constructor(Ext.apply({}, this.data), newId this.id);
    }


  • Sounds great Animal.

    I am not sure about "auto remove" as it may cause a repaint somewhere that the end developer wants to control (like me ;)). I do agree though it seems like a natural thing to do.

    DDView sounds like a great idea. Any chance you want to make it compatible with DataView in 2.0? There are a few nice existing plugins for DataView (DragSelector, LabelEditor) and a DD one would be the best plugin yet.

    FYI, your clone function above could be:

    clone : function() {
    return new this.constructor(Ext.apply({}, this.data), this.id);
    }

    I am adding it to the codebase, by I think I will call it copy. Sound ok?


  • Looks good.I don't know about upgrading to 2.0 yet. We're under pressure here to get things up and running, so it will be an Ext 1.1 implementation for a while yet.

    I'll tackle refactoring to 2.0 soon. Maybe autumn.


  • Could probably also do with


    clone : function() {
    var newData = {};
    for (var p in this.data) {
    newData[p] = this.data[p];
    }
    return new this.constructor(newData, this.id);
    }


    To aid in copy DnD operations.

    DnD using Ext.Records is the way to go!







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about Moving Records between Stores , Please add it free.