Results 1 to 6 of 6

Thread: Validating data coming from a server

  1. #1
    Sencha User
    Join Date
    Oct 2011
    Posts
    72
    Answers
    1
    Vote Rating
    3
      0  

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

  4. #3
    Sencha User
    Join Date
    Oct 2011
    Posts
    72
    Answers
    1
    Vote Rating
    3
      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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,553
    Answers
    3931
    Vote Rating
    1272
      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 @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

  6. #5
    Sencha User
    Join Date
    Oct 2011
    Posts
    72
    Answers
    1
    Vote Rating
    3
      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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,553
    Answers
    3931
    Vote Rating
    1272
      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 @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

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
  •