Results 1 to 8 of 8

Thread: Read the reader.rawData value from a PUT request's response.

  1. #1
    Sencha User
    Join Date
    Feb 2013
    Location
    NZ
    Posts
    122
    Answers
    6
    Vote Rating
    7
      0  

    Default Answered: Read the reader.rawData value from a PUT request's response.

    I am sending multiple lines from my grid as a PUT request to the server.

    The web service than deals with these lines and creates Header and Lines in the db. The service creates a Unique Header ID for each set of lines that send. The response of this PUT request is the HeaderID that it just created.

    I can see that ID on the
    Code:
    store.proxy.reader.rawData
    but I cant access it. See below:
    Capture.JPG

    Using
    Code:
    store.proxy.reader.rawData
    gives me [Object#object]]. Can somebody guide me how to access those two highlighted properties of the reader.

    Please note its a PUT request's response that I am showing in the pic.

    Thanks

  2. You can't do that. The sync is an asynchronous operation, by the time you're accessing it, the server hasn't got the data back yet. Listen to the write event on the store.

  3. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    18,608
    Answers
    676
    Vote Rating
    874
      0  

    Default

    When are you trying to access it? The console will keep updating to have the latest value, so it may not be ready by the time you're trying to get it.
    Evan Trimboli
    Twitter - @evantrimboli

  4. #3
    Sencha User
    Join Date
    Feb 2013
    Location
    NZ
    Posts
    122
    Answers
    6
    Vote Rating
    7
      0  

    Default Right after Store.sync().

    I am trying to access it after store.sync().

    Code:
    var grid = Ext.getCmp('reviewPicklistGrid');
    var selection = grid.getSelectionModel().getSelection();
    var store = Ext.getStore('GeneratePicklist');
    if (selection.length > 0){    
        store.loadRecords(selection);
        for(var i=0; i < selection.length; i++){
            //selection[i].data.isSelected = true;
            var record = store.getAt(i);        
            record.dirty = true;
            //console.log(record);
            if (selection.length == 1){
                store.proxy.url = PickList.globals.url + 'Orders/PrintPicklistSingle/';    
            }
            else{
                store.proxy.url = PickList.globals.url + 'Orders/PrintPicklist/';        
            }        
        }
    
    
        store.sync();
    }
    // This is where I am using it
    console.log(store.proxy.reader.rawData);
    var getId = store.proxy.reader.rawData;

  5. #4
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    18,608
    Answers
    676
    Vote Rating
    874
      1  

    Default

    You can't do that. The sync is an asynchronous operation, by the time you're accessing it, the server hasn't got the data back yet. Listen to the write event on the store.
    Evan Trimboli
    Twitter - @evantrimboli

  6. #5
    Sencha User
    Join Date
    Feb 2013
    Location
    NZ
    Posts
    122
    Answers
    6
    Vote Rating
    7
      0  

    Default Got hold of the Id.

    Thanks. That does the trick. I can see the ID on the write listener of the store.

    But the problem is how do I use that id in my controller code as above. This listener that I just created is on the store.

    Could you guide me how do I do that.

  7. #6
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    18,608
    Answers
    676
    Vote Rating
    874
      0  

    Default

    Not really sure what you mean, the way you add a listener is the same.
    Evan Trimboli
    Twitter - @evantrimboli

  8. #7
    Sencha User
    Join Date
    Feb 2013
    Location
    NZ
    Posts
    122
    Answers
    6
    Vote Rating
    7
      0  

    Default

    I mean

    I want to add the listener to the controller instead of the store itself. Can you guide me how to do that.

    I am looking at something like this. I got this from stackoverflow:

    Code:
    init : function () 
    {   
    this.getUsersStoreStore().addListener('write',this.finishedLoading, this);    
    this.control({    
        // widgets event handlers   
       });
    },
    But what goes in place of this.finishedLoading and what goes in this.control(). Never done this before. Sorry.

  9. #8
    Sencha User
    Join Date
    Feb 2013
    Location
    NZ
    Posts
    122
    Answers
    6
    Vote Rating
    7
      0  

    Default Got it running.

    Thanks mate.. The listening to Write event was what I needed. Cheers

Tags for this Thread

Posting Permissions

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