1. #1
    Ext User
    Join Date
    May 2008
    Posts
    20
    Vote Rating
    0
    sancho_0 is on a distinguished road

      0  

    Default update/create actions and DirectStore

    update/create actions and DirectStore


    Hi,

    I'm trying to implement the example in http://www.extjs.com/deploy/dev/exam...er/writer.html using a DirectStore and Ext.Direct functions in the api property, but I can't figure out what should return the server in the update/create actions.

    The same issue it's described in this post: http://www.extjs.com/forum/showthrea...510#post391510

    The first answer to that post, it works to avoid the Ext.data.DataReader exception, but if the server returns that, it's no possible to return anything else than the records updated. If I need to return any message or something like that, I can't.

    Does anyone implement something like this?? (a writer enabled DirectStore)

    Best Regards

  2. #2
    Ext User
    Join Date
    May 2008
    Posts
    20
    Vote Rating
    0
    sancho_0 is on a distinguished road

      0  

    Default


    Hey, nobody??

    I'm still looking for this...

    All I found it's that I should overwrite the functions onCreateRecords/onUpdateRecords in Ext.data.Store,

    Code:
     
    onCreateRecords : function(success, rs, data) {
            if (success === true) {
                try {
                    this.reader.realize(rs, data); 
                    this.reMap(rs);
                }
                .....
                .....
            }
    },
    to

    Code:
     
    onCreateRecords : function(success, rs, data) {
            if (success === true) {
                try {
                    this.reader.realize(rs, data[this.reader.meta.root]); 
                    this.reMap(rs);
                }
                .....
                .....
            }
    },
    am I right?? could this modification, break something else??

    HELP PLEASE!!!

  3. #3
    Ext User
    Join Date
    May 2008
    Posts
    20
    Vote Rating
    0
    sancho_0 is on a distinguished road

      0  

    Default


    Hey... it's me again...

    I also found a problem when the create/update action fails due to a server validation or something like that.

    The 'onWrite' function, in Ext.data.DirectProxy seems to be incomplete or something...

    Code:
    onWrite : function(action, trans, result, res, rs) { 
            this.fireEvent("write", this, action, result, res, rs, trans.arg); 
            trans.callback.call(trans.scope, result, res, true); 
        }
    At least, with this code, if the server returns successProperty===false, it doesn't matter..., the "write" event it's fired anyways and the callback it's called with 'true' as the last parameter...

    Looking the 'onWrite' function in Ext.data.HttpProxy, I guess that changes need to be made are

    Code:
    onWrite : function(action, trans, result, res, rs) {
            var records;        
            try {
                records = trans.reader.readRecords(result);
            } catch (e) {
                this.fireEvent('exception', this, 'response', action, trans, res, e);
                trans.callback.call(trans.scope, result, res, false);
                return;
            }
            
            success = result[trans.reader.meta.successProperty]
            if (success === false) {
                this.fireEvent('exception', this, 'remote', action, trans, result, rs);
            } else {
                this.fireEvent("write", this, action, result, res, rs, trans.arg);            
            }        
            trans.callback.call(trans.scope, result, res, success);
        }
    it's this a bug? am I loosing of something??

    Best Regards

  4. #4
    Ext User cerad's Avatar
    Join Date
    Dec 2007
    Posts
    226
    Vote Rating
    0
    cerad is on a distinguished road

      0  

    Default


    I ran in to the same issue in 3.1.0.

    Ext.data.DirectProxy seems to be ignoring the success flag.

    The fix works but I'm not convinced that being unable to create/update a record should be considered "exceptional". Lots of reasons the application might decide not to update.

    Seems like there should be a success/failure handlers of some sort.

  5. #5
    Ext User
    Join Date
    Aug 2009
    Posts
    6
    Vote Rating
    0
    maxigroovy is on a distinguished road

      0  

    Question


    I just can't get the create action to fire the 'write' event.
    It just does not find the method. Also the dirty flag is not cleared.

    On Update and Destroy there is no problem. Only the data / result value is not good extracted (on neither Update nor Create)
    The returning json is the same in update or create:

    Update result:
    Code:
    {"type":"rpc","tid":12,"action":"Management","method":"UpdateWorkers","result":{"success":true,"data":[{"NameID":"Kasper 4","Name":"Kasper 41","PhoneNumber":"1234        ","WorkScheduleName":"shsdfhsdfh"}],"total":1}}
    Create result:
    Code:
    {"type":"rpc","tid":10,"action":"Management","method":"CreateWorkers","result":{"success":true,"data":{"workers":[{"NameID":"ext-record-1","Name":"Kasper 4","PhoneNumber":"1234","WorkScheduleName":"shsdfhsdfh"}]},"total":1}}
    I'm using ExtJS 3.1 and ExtDirect for ASP.Net MVC 0.8.2.

    Any ideas?

  6. #6
    Ext User
    Join Date
    Dec 2007
    Location
    italy
    Posts
    120
    Vote Rating
    0
    tarini is on a distinguished road

      0  

    Default


    Hi to all,
    I've got the same problem in create/update... here's my request/response transactions

    create:

    extjs request:
    Code:
    {"action":"MovieService","method":"create","data":[{"entityList":[{"title":"title","year":1900,"summary":"summary"}]}],"type":"rpc","tid":3}
    server response:
    Code:
    {"result":{"entityList":[{"title":"title changed by server to test","year":"1900",
            "summary":"summary","id":100}],"total":1},"tid":3,"action":"MovieService","method":
      "create","type":"rpc"}
    it doesn't work because my JsonReader cannot find data property to "realize" phantom record -_-
    (it throws Ext.data.DataReader: #realize was called with invalid remote-data. Please see the docs for DataReader#realize and review your DataReader configuration.)

    update:

    extjs request:
    Code:
    {"action":"MovieService","method":"update","data":[{"entityList":[{"title":"new title","year":1994,"summary":"Summary","id":3}]}],"type":"rpc","tid":5}
    server response:
    Code:
    {"result":{"entityList":[{"title":"new title changed by server to test","year":
            "1994","summary":"summary","id":3}],
        "total":1},"tid":5,"action":"MovieService","method":"update","type":
      "rpc"}
    in this case record is flagged as updated (the red triangle from grid is removed) but title doesn't change


    where I am wrong?

    thanks

  7. #7
    Ext User
    Join Date
    Jan 2010
    Posts
    5
    Vote Rating
    0
    tsedeke is on a distinguished road

      0  

    Default I got it working.

    I got it working.


    Have the same problem as described above. Tracing the post and response from example page above.

    I got it working.

    For 'create' you need as response the full record from inserted record. This will be also good for update, cause databases often has triggers which change the entry values. So in PHP the response can look like this:
    PHP Code:
    $datarow $zfDBtable->find('<recordID>')->asArray();
    $res = array(
              
    'success' => true,
              
    'message' => 'insert/update done',
              
    'dataroot' => $datarow
              
    );
    echo 
    json_encode($res); 
    This is just an example. The values 'dataroot' must be change to your settings in ext store object. I use here also the Zend Framework for database activities.

    Hope that help's someone.

  8. #8
    Sencha User khebs@live.com's Avatar
    Join Date
    Mar 2008
    Posts
    83
    Vote Rating
    0
    khebs@live.com is on a distinguished road

      0  

    Default


    Quote Originally Posted by tsedeke View Post
    Have the same problem as described above. Tracing the post and response from example page above.

    I got it working.

    For 'create' you need as response the full record from inserted record. This will be also good for update, cause databases often has triggers which change the entry values. So in PHP the response can look like this:
    PHP Code:
    $datarow $zfDBtable->find('<recordID>')->asArray();
    $res = array(
              
    'success' => true,
              
    'message' => 'insert/update done',
              
    'dataroot' => $datarow
              
    );
    echo 
    json_encode($res); 
    This is just an example. The values 'dataroot' must be change to your settings in ext store object. I use here also the Zend Framework for database activities.

    Hope that help's someone.
    Hi, did you apply any patches/overrides in Ext.Direct? i tried this it didnt worked for me, would you be so kind to post a sample post & response value? did the successProperty recognized when it is False in your code?

  9. #9
    Ext User cerad's Avatar
    Join Date
    Dec 2007
    Posts
    226
    Vote Rating
    0
    cerad is on a distinguished road

      0  

    Default


    Quote Originally Posted by khebs@live.com View Post
    Hi, did you apply any patches/overrides in Ext.Direct? i tried this it didnt worked for me, would you be so kind to post a sample post & response value? did the successProperty recognized when it is False in your code?
    http://www.extjs.com/forum/showthread.php?t=91793

    As far as I can tell, ignoring the successProperty is a feature not a bug.

  10. #10
    Ext User
    Join Date
    Jan 2010
    Posts
    5
    Vote Rating
    0
    tsedeke is on a distinguished road

      0  

    Default


    Right it ignore the Success property. Think you have to read it self and react.
    This is not necessary for me. When I got a database error I send the hole error or I create my own error in Zend Framework. So I do not send the row back but the error.
    Im my datastore I have a exception listener:
    PHP Code:
    listeners: {
            
    exception: function(proxytypeactionoptionsresponsearg){
                    
    Ext.Msg.show({
                        
    title        'REMOTE EXCEPTION',
                        
    msg            response.responseText,
                        
    icon        Ext.MessageBox.ERROR,
                        
    buttons        Ext.Msg.OK
                    
    });
            } 

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi