1. #1
    Sencha User
    Join Date
    Jun 2012
    Posts
    4
    Vote Rating
    0
    santhony7 is on a distinguished road

      0  

    Default Using one model for two different Stores

    Using one model for two different Stores


    First time posting! This is great because, so far, I have found Architect 2 and EXT to be very intuitive and easy to learn. Well done.

    So here is my issue: I am using a single Model bound to two different Stores. One store fetches very basic data (Student name and ID) and the other store fetches detailed data (Address, Phone, Courses). However, the detail view shows all data and the server returns values under different names. So if I map to one, I lose the other. Example:

    Basic data API returns: stnName, stnId
    Detail data API returns: studentName, studentID

    So what would my fieldName be for each of those?

    Just an idea: Is there a way to change the field mapping before the API is called?

    And, yes, I want to shoot the developer who made the API.

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,983
    Vote Rating
    455
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    I would suggest including your details as a nested object in your data instead of hassling with 1 model for 2 different stores:
    http://www.sencha.com/forum/showthread.php?219981

    Regards,
    Scott.

  3. #3
    Sencha User
    Join Date
    Jun 2012
    Posts
    4
    Vote Rating
    0
    santhony7 is on a distinguished road

      0  

    Default


    This is an interesting solution but is not ideal. I don't think that a Model should be designed around a single API. What would be cool is if the Store had the ability to map its fields to the Model fields. The default behavior would still exist, Models bound to Stores get populated with matched (or mapped within the Model) fields but if the Store has a mapping, it would be used instead.

    Maybe I am just saying that Model field mappings should be moved to the Store?

    Just some thoughts.

  4. #4
    Sencha User
    Join Date
    Jun 2011
    Location
    Ukraine, Mykolayiv
    Posts
    99
    Vote Rating
    1
    rsqw is on a distinguished road

      0  

    Default


    nice thoughts

Thread Participants: 2

Tags for this Thread