1. #1
    Sencha User
    Join Date
    Oct 2011
    Posts
    72
    Answers
    1
    Vote Rating
    3
    TDeBailleul is on a distinguished road

      0  

    Default Answered: Validating data coming from a server

    Answered: Validating data coming from a server


    I have a store that loads data through a ajax proxy. What I would like to do is to check the data (like the value of an attribute) before the store loads.

    I have already tried to do it with the 'before load' event of a store, but somehow when I try to get the records from there with operation.getRecords(); it gives me an empty array..

    I know there is some validation system in Sencha Touch but it does not seem to include data coming from a server

    Does anyone have a solution for this ?

    Thanks

  2. If you want to validate the data before it makes it into the store then you need to hook into the reader to validate the data before the reader gives it up to the proxy.

    The beforeload event of the store fires before the store sends the request.

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,220
    Answers
    3522
    Vote Rating
    859
    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


    If you want to validate the data before it makes it into the store then you need to hook into the reader to validate the data before the reader gives it up to the proxy.

    The beforeload event of the store fires before the store sends the request.
    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.

  4. #3
    Sencha User
    Join Date
    Oct 2011
    Posts
    72
    Answers
    1
    Vote Rating
    3
    TDeBailleul is on a distinguished road

      0  

    Default


    Could you please be more specific about "to hook into the reader" ? I don't really know what it means.

  5. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,220
    Answers
    3522
    Vote Rating
    859
    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


    Quote Originally Posted by TDeBailleul View Post
    Could you please be more specific about "to hook into the reader" ? I don't really know what it means.
    You can extend the reader (json or xml...) and then validate the data in getResponseData (the method that decodes the response to JavaScript).
    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.

  6. #5
    Sencha User
    Join Date
    Oct 2011
    Posts
    72
    Answers
    1
    Vote Rating
    3
    TDeBailleul is on a distinguished road

      0  

    Default


    Ok, I've tried this but it doesn't seem to work, any idea why ?

    Code:
    reader: {
            rootProperty: 'data',
            getResponseData: function(response){
              console.log(response);
              return response;
            }
          }

  7. #6
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,220
    Answers
    3522
    Vote Rating
    859
    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


    Because you can't override methods when creating an instance. You will need to extend the reader or make an override as I have said.
    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.

Thread Participants: 1

Tags for this Thread