1. #11
    Sencha - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Vote Rating
    113
    vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all

      0  

    Default


    Action of calling store.sync() does not fire event if the returned value contains {success: false}. It will fire 'write' event on {success: true}.
    There are some ways to resolve your request:
    - extend your store from Ext.data.Store and override onProxyWrite() to handle the returned value.
    - Instead of calling <store>.sync(), just call <store>.create(data, options), <store>.update(options), <store>.destroy(options). This way, you can define a callback to handler the returned value.

    listeners: {
    'edit': function (e, eOpts) {
    store.sync();
    e.record.commit();
    },
    BTW, you should not call e.record.commit(). This will be done by framework basing on the returned value from server

  2. #12
    Sencha User
    Join Date
    Mar 2012
    Posts
    43
    Vote Rating
    0
    durgaprasadn is on a distinguished road

      0  

    Default


    Thank you very much vietits for your reply. Your replies are very much informative and really appreciate your time and knowledge.


    I have one more question. Right now the json object is posted as follows:


    {"data":[{"linkId":"","linkType":8,"linkUrl":"tw","vanityUrl":"tes","divisionId":0,"description":"","comments":"tds","createdOn":null,"createdBy":"","updatedOn":null,"updatedBy":"td","sourceCode":"","businessUnitId":0,"locale":""}]}.


    When the new vanity url record is created, I want the server meaning database to take care of the linkId value and dont want to send the value from the front end. By default my extjs framework its initializing some value and sending it.


    How to make sure in the json object, not to send the linkId as part of the json request, when we create the new record as I want that link id to be created at the server end.


    --Durga

  3. #13
    Sencha - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Vote Rating
    113
    vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all

      0  

    Default


    I think linkId (in your case is the key field) is still needed in case you updating/destroying records. In case of creating, it only contains empty string. In server side, you just ignore it and generate new id for the record. One thing to remember is that you must return created records with new id to client side to update their data in store.

    Also, if you want a field from your client data not to be sent to server side, just define it with persist set to false in your model definition.

  4. #14
    Sencha User
    Join Date
    Mar 2012
    Posts
    43
    Vote Rating
    0
    durgaprasadn is on a distinguished road

      0  

    Default


    Thanks for your reply vietits. Thanks for patience in answering my questions.

    if we get the updated record with the new linkid from the server, do we need to handle any thing in the client side or would the framework take care of it.

    When I try to integrate the back end service for delete, I am seeing the data posted as

    {"data":[{"id":null}]}. I have added the model idProperty to linkId, at the first place I am not sure why still id is coming in the request. second is how to populate that correct selected value.

    My store api is as follows:

    api: {
    // all actions except the following will use above url
    read : 'http://localhost:4502/apps/myvanity/getVanityUrl/',
    create : 'http://localhost:4502/apps/myvanity/insertOrUpdateVanityUrl',
    update : 'http://localhost:4502/apps/myvanity/insertOrUpdateVanityUrl',
    destroy : 'http://localhost:4502/apps/myvanity/deleteVanityUrl'
    }

    My toolbar for remove and store.sync() for destroy being invoked as follows in the handler:

    tbar : [{
    itemId: 'removeVanityUrl',
    text: 'Remove VanityUrl',
    iconCls: 'vanityurl-remove',
    handler: function() {
    var sm = grid.getSelectionModel();
    rowEditing.cancelEdit();
    store.sync();//not sure this is the right way to invoke the destroy method though.
    store.remove(sm.getSelection());
    if (store.getCount() > 0) {
    sm.select(0);
    }
    },
    disabled: true
    }]

    //disabling the rows in a grid

    selectionchange': function(view, records) {
    grid.down('#removeVanityUrl').setDisabled(!records.length);
    }


    --Durga

  5. #15
    Sencha - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Vote Rating
    113
    vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all

      0  

    Default


    Quote Originally Posted by durgaprasadn View Post
    if we get the updated record with the new linkid from the server, do we need to handle any thing in the client side or would the framework take care of it.
    If there is any change in records you should return them to the client to update them in store.

    When I try to integrate the back end service for delete, I am seeing the data posted as

    {"data":[{"id":null}]}. I have added the model idProperty to linkId, at the first place I am not sure why still id is coming in the request. second is how to populate that correct selected value.
    What's the action linked to this data?

    My toolbar for remove and store.sync() for destroy being invoked as follows in the handler:
    tbar : [{
    itemId: 'removeVanityUrl',
    text: 'Remove VanityUrl',
    iconCls: 'vanityurl-remove',
    handler: function() {
    var sm = grid.getSelectionModel();
    rowEditing.cancelEdit();
    store.sync();//not sure this is the right way to invoke the destroy method though.
    store.remove(sm.getSelection());
    if (store.getCount() > 0) {
    sm.select(0);
    }
    },
    disabled: true
    }]
    You should call store.sync() after calling store.remove(sm.getSelection());

  6. #16
    Sencha User
    Join Date
    Mar 2012
    Posts
    43
    Vote Rating
    0
    durgaprasadn is on a distinguished road

      0  

    Default



    Thanks for your responses vietits. Please find my comments inline.

    if we get the updated record with the new linkid from the server, do we need to handle any thing in the client side or would the framework take care of it.




    If there is any change in records you should return them to the client to update them in store.

    [Durga] lets say if the server returns the return json data as follows, when the new record is added. Already that data is present in the store except the sync of link id that is returned from the server.

    {"success":true,
    "data":[{"linkId":2,"linkType":31,"linkUrl":"860187036","vanityUrl":"","divisionId":0,"description":"","comments":"","sourceCode":"","businessUnitId":1,"createdOn":1191456429097,"createdBy":"7776","locale":"EN_US"}]}

    What should I do to sync that id with the existing data?

    When I try to integrate the back end service for delete, I am seeing the data posted as

    {"data":[{"id":null}]}. I have added the model idProperty to linkId, at the first place I am not sure why still id is coming in the request. second is how to populate that correct selected value.



    What's the action linked to this data?

    [Durga] the action linked to the data is the remove action in the tool bar listed below.

    One behaviour I have seen is every time the id is getting added.

    first time delete json data is : "data":[{"id":null}]}

    second time delete json data is : {"data":[{"id":null},{"id":null}]}

    third time delete json data is : {"data":[{"id":null},{"id":null},
    {"id":null}]}

    My toolbar for remove and store.sync() for destroy being invoked as follows in the handler:



    tbar : [{
    itemId: 'removeVanityUrl',
    text: 'Remove VanityUrl',
    iconCls: 'vanityurl-remove',
    handler: function() {
    var sm = grid.getSelectionModel();
    rowEditing.cancelEdit();
    store.sync();//not sure this is the right way to invoke the destroy method though.
    store.remove(sm.getSelection());
    if (store.getCount() > 0) {
    sm.select(0);
    }
    },
    disabled: true
    }]



    You should call store.sync() after calling store.remove(sm.getSelection());

    [Durga] I have called the store.sync() after store.remove(sm.getSelection()), but it did not make a difference in the json data thats being listed above.

    --Durga

  7. #17
    Sencha - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Vote Rating
    113
    vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all

      0  

    Default


    Quote Originally Posted by durgaprasadn View Post
    [Durga] lets say if the server returns the return json data as follows, when the new record is added. Already that data is present in the store except the sync of link id that is returned from the server.


    {"success":true,
    "data":[{"linkId":2,"linkType":31,"linkUrl":"860187036","vanityUrl":"","divisionId":0,"description":"","comments":"","sourceCode":"","businessUnitId":1,"createdOn":1191456429097,"createdBy":"7776","locale":"EN_US"}]}


    What should I do to sync that id with the existing data?
    You have to do nothing. All the returned data will replace the current data in the store by the framework.

    When I try to integrate the back end service for delete, I am seeing the data posted as
    {"data":[{"id":null}]}. I have added the model idProperty to linkId, at the first place I am not sure why still id is coming in the request. second is how to populate that correct selected value.


    What's the action linked to this data?


    [Durga] the action linked to the data is the remove action in the tool bar listed below.


    One behaviour I have seen is every time the id is getting added.


    first time delete json data is : "data":[{"id":null}]}


    second time delete json data is : {"data":[{"id":null},{"id":null}]}


    third time delete json data is : {"data":[{"id":null},{"id":null},{"id":null}]}
    It's strange because when you call store.remove(), the store will only marked for sync with records that are not phantom.

    My toolbar for remove and store.sync() for destroy being invoked as follows in the handler:
    tbar : [{
    itemId: 'removeVanityUrl',
    text: 'Remove VanityUrl',
    iconCls: 'vanityurl-remove',
    handler: function() {
    var sm = grid.getSelectionModel();
    rowEditing.cancelEdit();
    store.sync();//not sure this is the right way to invoke the destroy method though.
    store.remove(sm.getSelection());
    if (store.getCount() > 0) {
    sm.select(0);
    }
    },
    disabled: true
    }]


    You should call store.sync() after calling store.remove(sm.getSelection());


    [Durga] I have called the store.sync() after store.remove(sm.getSelection()), but it did not make a difference in the json data thats being listed above.
    You should call store.remove() before store.sync() because it will remove selected records from store, marked them for sync. If you call it after calling store.sync(), it will marked removed records for next sync.

  8. #18
    Sencha User
    Join Date
    Mar 2012
    Posts
    43
    Vote Rating
    0
    durgaprasadn is on a distinguished road

      0  

    Default


    Thank you very much for your response Sir!! I appreciate your time and knowledge

    Even though the json data is {"success":false} , I could see the record got added into the grid. By looking at the code i thought sucess:false would not fire the write event. Not sure why its adding into the grid. Should I do any thing extra to not add into the grid.
    But when I reload the grid, I am not seeing that record which is desired though.

    Also my service is just returning the json data {"success":true} and not the inserted record as we discussed, As an alternative, can I reload the store to get the fresh data with sync up of id after the addition operation(store.sync()).

    I have taken the source code from the AbstractStore.js, but not sure how to override the OnProxyWrite to write my own call backs for create, update and destroy events. It would be great if you could give me some sample code.


    /** * @private * Callback for any write Operation over the Proxy. Updates the Store's MixedCollection to reflect * the updates provided by the Proxy */ onProxyWrite: function(operation) { var me = this, success = operation.wasSuccessful(), records = operation.getRecords(); switch (operation.action) { case 'create': me.onCreateRecords(records, operation, success); break; case 'update': me.onUpdateRecords(records, operation, success); break; case 'destroy': me.onDestroyRecords(records, operation, success); break; } if (success) { me.fireEvent('write', me, operation); me.fireEvent('datachanged', me); } //this is a callback that would have been passed to the 'create', 'update' or 'destroy' function and is optional Ext.callback(operation.callback, operation.scope || me, [records, operation, success]); },--Durga

  9. #19
    Sencha - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Vote Rating
    113
    vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all

      0  

    Default


    Quote Originally Posted by durgaprasadn View Post
    Even though the json data is {"success":false} , I could see the record got added into the grid. By looking at the code i thought sucess:false would not fire the write event. Not sure why its adding into the grid. Should I do any thing extra to not add into the grid.


    But when I reload the grid, I am not seeing that record which is desired though.
    When you adding new records to store, it will be shown on the grid. After sync, if the returned result is success, the returned data will be updated in store and changes will be shown on grid. So, if returned result is not successful, the grid still shows the new record as it is before sync. This record often marked with red color at cell corners.
    Also my service is just returning the json data {"success":true} and not the inserted record as we discussed, As an alternative, can I reload the store to get the fresh data with sync up of id after the addition operation(store.sync()).
    If you just return json data with {'success': true}, the new record in store has no id and it is still marked as new record and it will be sync next time.

    Of course, you can reload store to reflex what you have on server, but it will load all the data (with limit by pageSize), not only newly created one.

    I have taken the source code from the AbstractStore.js, but not sure how to override the OnProxyWrite to write my own call backs for create, update and destroy events. It would be great if you could give me some sample code.


    /** * @private * Callback for any write Operation over the Proxy. Updates the Store's MixedCollection to reflect * the updates provided by the Proxy */ onProxyWrite: function(operation) { var me = this, success = operation.wasSuccessful(), records = operation.getRecords(); switch (operation.action) { case 'create': me.onCreateRecords(records, operation, success); break; case 'update': me.onUpdateRecords(records, operation, success); break; case 'destroy': me.onDestroyRecords(records, operation, success); break; } if (success) { me.fireEvent('write', me, operation); me.fireEvent('datachanged', me); } //this is a callback that would have been passed to the 'create', 'update' or 'destroy' function and is optional Ext.callback(operation.callback, operation.scope || me, [records, operation, success]); },--Durga
    To handle onProxyWrite(), you should extend your data from Ext.data.Store and then use this new class for instantiating your stores.
    Code:
    Ext.define('MyOwnStore', {
        extend: 'Ext.data.Store',
        onProxyWrite: function(operation){
            var me = this;
            me.callParent(arguments);
            if(!operation.wasSuccessful()){
                // put your handling code here
            }
        }
    })
    The other way is using interceptBefore() or interceptAfter()
    Code:
    Ext.Function.interceptAfter(store, 'onProxyWrite', function(operation){
        if(!operation.wasSuccessful()){
            // your code here
       }
    })

  10. #20
    Sencha User
    Join Date
    Mar 2012
    Posts
    43
    Vote Rating
    0
    durgaprasadn is on a distinguished road

      0  

    Default


    Thanks vietits for your responses. I am able to solve most of the problems, but got struck with this problem. I appreicate your responses sir.

    I am doing the update at the grid and calling the store.sync() in the edit listener as follows and I am seeing in the firebug the json object with id and modified properties.


    {"vanityUrls":[{"linkUrl":"vanity3testing","linkId":29926}]}.


    Service is expecting the complete object as defined in the model as grid client has all those values. But when I do store.sync(), it is just sending the modified properties.


    service expecting all the values for that record along with modified values as follows:{"vanityUrls":[{"linkId":29927,"linkType":0,"linkUrl":"vanity4testing","divisionId":0,"businessUnitId":1,"updatedOn":1334697924830,"locale":"EN_US"}]}


    My model object
    Ext.define('VanityUrl', {
    extend: 'Ext.data.Model',
    idProperty:'linkId',
    fields: [
    {name:'linkId', type: 'int'},
    { name:'linkType', type: 'int'},
    { name: 'linkUrl', type: 'string'},
    { name: 'vanityUrl', type: 'string'},
    { name: 'divisionId', type: 'int'},
    { name: 'description', type: 'string'},
    { name: 'comments', type: 'string'},
    {name: 'createdOn', type: 'date', dateFormat: 'Y-m-d'},
    {name: 'createdBy', type: 'string'},
    {name: 'updatedOn', type: 'date', dateFormat: 'Y-m-d'},
    {name: 'updatedBy', type: 'string'},
    {name: 'sourceCode', type: 'string'},
    {name: 'businessUnitId', type: 'int'},
    {name: 'locale', type: 'string'}
    ]
    });


    listener where i am calling the store.sync()


    listeners: {
    'edit': function (e, eOpts) {
    alert('edit row editing');
    alert(e.record.data.vanityUrl);
    store.sync();


    // e.record.commit();
    },
    'selectionchange': function(view, records) {
    grid.down('#removeVanityUrl').setDisabled(!records.length);
    },
    'beforeedit': function (e, eOpts) {
    var linkType = e.record.data.linkType;
    if(linkType != 8)
    {
    return false;
    }
    }
    }


    --Durga

Thread Participants: 1

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..."