Results 1 to 3 of 3

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

  1. #1
    Sencha User
    Join Date
    Nov 2011
    Posts
    20
    Vote Rating
    0
      0  

    Question 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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,553
    Answers
    3931
    Vote Rating
    1272
      0  

    Default

    When does the write event happen?
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  3. #3
    Sencha User
    Join Date
    Nov 2011
    Posts
    20
    Vote Rating
    0
      0  

    Question 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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •