1. #1
    Sencha User
    Join Date
    Jun 2011
    Posts
    6
    Vote Rating
    0
    vedmalex is on a distinguished road

      0  

    Default Answered: [ExtJS 4.1.1RC1] model with idgen -> new phantom = false. why?

    Answered: [ExtJS 4.1.1RC1] model with idgen -> new phantom = false. why?


    The issue: Creating new Records with model that uses idgen is not a phantom
    because of the next statement in constructor of model

    Code:
    if (me.getId()) {
                me.phantom = false;        
    } else if (me.phantom) {
                newId = me.idgen.generate();
                if (newId !== null) {
                    me.setId(newId);
                }
    }
    Model.setId code:
    Code:
    setId: function(id) {
            this.set(this.idProperty, id);
            this.phantom  = !(id || id === 0);
    },
    here in setId code whether or not id is generated by idgen the record marked as not phantom
    here the example code
    Attached Files

  2. A phantom record doesn't have an id. Lets take a common scenario:

    1) You load a store with 5 records, these come from the server and all have an id assigned.
    2) You add a new record to the store. It doesn't have an id, because it has yet to be created on the server (hence, phantom).
    3) You run a sync on the store, the server assigns a new id to the record and sends it back to the client.
    4) The record is no longer a phantom.

    In your case, the idgen is just taking the place of the server.

  3. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,125
    Answers
    347
    Vote Rating
    514
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    By giving the model an id, that makes it not a phantom record anymore.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  4. #3
    Sencha User
    Join Date
    Jun 2011
    Posts
    6
    Vote Rating
    0
    vedmalex is on a distinguished road

      0  

    Default


    so how then implement idgenerator and what is "the idgen" for?
    i see that there is clientIdPorperty, but how can i assign autmaticly the value for the clientId?
    any scenario, example, i didn't see any in the documantation.
    and how the get new records from the store?

  5. #4
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,125
    Answers
    347
    Vote Rating
    514
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    A phantom record doesn't have an id. Lets take a common scenario:

    1) You load a store with 5 records, these come from the server and all have an id assigned.
    2) You add a new record to the store. It doesn't have an id, because it has yet to be created on the server (hence, phantom).
    3) You run a sync on the store, the server assigns a new id to the record and sends it back to the client.
    4) The record is no longer a phantom.

    In your case, the idgen is just taking the place of the server.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  6. #5
    Sencha User
    Join Date
    Jun 2011
    Posts
    6
    Vote Rating
    0
    vedmalex is on a distinguished road

      0  

    Default


    it is doubtful for my task
    hense i don't have a way to push mass or records, that is related each other,
    from the client.
    personnaly i use idgen to provide foreign key for "associations" and use it to connect objects in mongoDb (no referencial integrity at all).

    I wonder, if there any way to do what i do(commit tree of connected objects), in relation database -- because client must at first save the master record and then connected one because of the integrity checking - foreign key.

    the clientIdProperty didn't suits for my solution at all.

    may be invent a state machine for the record using which developer and store will determine that record is newly created (
    thinking out loud).

  7. #6
    Sencha Complete Member
    Join Date
    Dec 2010
    Posts
    58
    Answers
    1
    Vote Rating
    1
    ALEITZ is on a distinguished road

      0  

    Default Thanks for the advice BUT

    Thanks for the advice BUT


    Hi,
    Although I agree guidance regarding DB's assigning ID's and I think the 'phantom' record functionality for new records is great the issue I have is that in my situation I NEED TO CREATE THE ID's on the CLIENT.

    There's no reason why you need to enforce this restriction on not syncing new records with id's created on the client.
    The fact that I can't add a record to a store with an ID and have it sync via the store's proxy is a defect.

Thread Participants: 2

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar