1. #1
    Sencha User
    Join Date
    Nov 2011
    Posts
    20
    Vote Rating
    0
    simonr26 is on a distinguished road

      0  

    Question Unanswered: How detect that server CRUD operations have been successful?

    Unanswered: How detect that server CRUD operations have been successful?


    Hello,
    How can I determine if Create, Update, Delete operations
    complete successfully? I need to indicate to the user
    if a server CRUD operation fails.


    I have created store as below.
    There are 3 event handlers for the 3 operations - each makes
    changes to the store and performs a sync.
    The controller actions are correctly invoked, and I return
    similar to the following:
    {"success": true,"dests": {"id":456,"res":10508,"descr":"updated"}}


    I can determine success of a read by using the store.load callback
    function in conjunction with the successProperty config.
    It may be possible to determine if successful updates/edits using the
    successProperty, since if response returns false, a dirty record
    seems to be shown?
    The successProperty doesn't seem to be relevant to create/delete
    operations.




    onAdd: function (btn) {
    var gridId = Ext.getCmp('gridpanelid');
    gridId.store.add(new APP.model.ModelClass);
    gridId.store.sync();
    },
    onEdit: function (btn) {
    var gridId = Ext.getCmp('gridpanelid');
    var sel = gridId.getSelectionModel().getSelection()[0];
    sel.set('descr', 'updated');
    gridId.store.sync();
    },
    onDel: function (btn) {
    var gridId = Ext.getCmp('gridpanelid');
    var sel = gridId.getSelectionModel().getSelection()[0];
    gridId.store.remove(s);
    gridId.store.sync();
    }


    var newWriter = Ext.create('Ext.data.writer.Json',{
    })


    Ext.define('APP.store.TheStores', {
    extend: 'Ext.data.Store',
    model: 'APP.model.ModelClass',
    proxy: {
    type: 'ajax',
    api: {
    create: 'dest/create',
    read: 'dest/list',
    update: 'dest/update',
    destroy:'dest/destroy'
    },
    reader: {
    type: 'json',
    successProperty: 'success'
    },
    writer: newWriter
    }
    }),...


    kind regards,
    Simon

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,344
    Answers
    3541
    Vote Rating
    847
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    When does the write event happen?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Nov 2011
    Posts
    20
    Vote Rating
    0
    simonr26 is on a distinguished road

      0  

    Question Write occurs following sync

    Write occurs following sync


    Hello,

    thank you for your reply.
    Following the add,set,remove methods, the store is updated.
    The sync() method then causes the writer to post the altered data
    to the server using the url.
    However I do not know how the client can determine if the server
    successfully updated the database. e.g. is there a way ext js 4 can
    interpret any response?

    kind regards,
    Simon

Thread Participants: 1