[CLOSED] Record changes not being reflected

  1. #1

    [CLOSED] Record changes not being reflected

    Hi Guys

    I have a directevent on a button where I do a pre-submit check using

    de.Click.Before = "gridCheck";
    This checks a bit of data if false then updates all the rows in the grid.

     /* Check is permitted  */
            Ext.net.DirectMethod.request({
                url: 'ExtNet/permitted?RNCY=' + App.RNCY.getValue(),
                success: function (result) {
    
                    if (result == false) {
                        alert('Approval Needed');
                       
                        var grid = Ext.getCmp("GridPanel_" + extraParams.tabId);
                        grid.getStore().each(function (record) {
                            record.set('StatusId', 3010);
                        });
                    }
    
                }
            });
    The Alert fires and using firebug I can see the record.set('StatusId', 3010); is getting executed but the changes are not making it to the database. do I need to put an extra step in to force an update of the store before the directevent get processed?
    Last edited by Daniil; Jun 04, 2013 at 5:10 AM. Reason: [CLOSED]
  2. #2
    Hello!

    Sorry, I don't quite understand you. As I see you call the DirectMethod and then update records in the store. However, I don't see any synchronization or update of database on server. Can you clarify?
  3. #3
    Hi,

    Just to clarify. A DirectMethod's success handler is called asynchronously after a request is actually executed, i.e. a client gets a response from server.

    The following sequence happens.

    1. DirectEvent's Before handler is executed.
    2. DirectMethod request goes to server.
    3. DirectEvent request goes to server.
    4. Client gets DirectEvent and DirectMethod requests asynchronously. DirectMethod's success handler is executed. What is more, it has more chances to get the DirectMethod response first, since it goes to server first.

    Well, the main point that the DirectMethod's success handler is executed after the DirectEvent request in your scenario.
  4. #4
    Quote Originally Posted by Daniil View Post
    Hi,

    Just to clarify. A DirectMethod's success handler is called asynchronously after a request is actually executed, i.e. a client gets a response from server.

    The following sequence happens.

    1. DirectEvent's Before handler is executed.
    2. DirectMethod request goes to server.
    3. DirectEvent request goes to server.
    4. Client gets DirectEvent and DirectMethod requests asynchronously. DirectMethod's success handler is executed. What is more, it has more chances to get the DirectMethod response first, since it goes to server first.

    Well, the main point that the DirectMethod's success handler is executed after the DirectEvent request in your scenario.
    Nuts. This will explain why when I do a code break I can see the change on the grid. Is there a way round this? maybe listener on the button as well as a direct event?
    Last edited by OriCoder; May 30, 2013 at 11:20 AM.
  5. #5
    I can't suggest anything concrete, because I am not getting your scenario yet.

    Please clarify why do you call a DirectMethod within a DirectEvent's Before?
  6. #6
    So the work flow is as follows.

    Grid is sumbited to the controller with a button(Direct Event).

    Before the grid is suibmited I want to perform a mixture of client and server side validation on the data being submitted. Which is why i am using the .Before in the direct event.

    Some of the data being checked is dynamic so need to check against the server database when submitting during the .Before hence using the directMethod call to do this.

    Depending on the result that comes back from the directMethod this may change some of the data on the grid which needs to happen before the grid is passed in the direct event, so that the changes take effect.


    ....Hope this helps
  7. #7
    OK, it gets clear.

    So, I can't see any other way except waiting for a response of a DirectMethod, then submitting a GridPanel.

    You can organize it replacing the Click DirectEvent with a Click Listener + a DirectMethod call. Then call that new DirectMethod within a success handler or your existing "permission" DirectMethod.
  8. #8
    Quote Originally Posted by Daniil View Post
    OK, it gets clear.

    So, I can't see any other way except waiting for a response of a DirectMethod, then submitting a GridPanel.

    You can organize it replacing the Click DirectEvent with a Click Listener + a DirectMethod call. Then call that new DirectMethod within a success handler or your existing "permission" DirectMethod.
    I think for what I am doing I am going to have to use the client side validation for my "hard" stops on the grid this means I can take out the directmethod from the client side. Then I'll have to commit the grid to the db and read it back doing a "post trade" validation direct with the db in c#.

    Not ideal but should work.
  9. #9
    Sure, if such a way is appropriate in your scenario, it should work.

Similar Threads

  1. Replies: 0
    Last Post: Nov 20, 2012, 1:08 PM
  2. Replies: 1
    Last Post: Nov 05, 2012, 8:38 AM
  3. Replies: 16
    Last Post: May 26, 2011, 10:23 PM
  4. Add record to store
    By Argons in forum 1.x Help
    Replies: 4
    Last Post: Aug 05, 2009, 12:40 AM
  5. [CLOSED] Adding a new Store Record - Not a Record object
    By Steve in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: May 15, 2009, 7:40 AM

Tags for this Thread

Posting Permissions