1. #1
    Sencha User
    Join Date
    Apr 2013
    Posts
    11
    Vote Rating
    0
    Answers
    1
    metric152 is on a distinguished road

      0  

    Default Unanswered: Is there a better method for getting the name of a model from a record.

    Unanswered: Is there a better method for getting the name of a model from a record.


    I found the property [record].modelName but it's no where in the documentation for sencha. I don't want to rely on something that might go away so I'm curious if there's a better way to get the model data is tied to.

  2. #2
    Sencha Premium Member
    Join Date
    Feb 2012
    Location
    Berne, Switzerland
    Posts
    714
    Vote Rating
    42
    Answers
    41
    ingo.hefti has a spectacular aura about ingo.hefti has a spectacular aura about ingo.hefti has a spectacular aura about

      0  

    Default


    Why would you do/need that for? Can you further explain your scenario?

  3. #3
    Sencha User
    Join Date
    Apr 2013
    Posts
    11
    Vote Rating
    0
    Answers
    1
    metric152 is on a distinguished road

      0  

    Default


    I'm reusing the base structure of a listview added to a navigationview and changing the store or the listview. I'm leaving the disclose and tap listener the same.

    I not realize it's probably better to create a whole new list view with a different listener for the tap but I was trying to throw something together quickly. It seemed like there should be a way to see the model a record is tied to, but it's probably better to have a 1-1 relationship for a record and a listview.

  4. #4
    Sencha Premium Member
    Join Date
    Feb 2012
    Location
    Berne, Switzerland
    Posts
    714
    Vote Rating
    42
    Answers
    41
    ingo.hefti has a spectacular aura about ingo.hefti has a spectacular aura about ingo.hefti has a spectacular aura about

      0  

    Default


    Quote Originally Posted by metric152 View Post
    It seemed like there should be a way to see the model a record is tied to, but it's probably better to have a 1-1 relationship for a record and a listview.
    I think there is. When looking at a record, it has a STORES array and each store has a MODEL property. So that should be possible.
    But I agree with the last part of your sentence. I also prefer it 'the clean way'. Makes it a lot more easier to maintain the code...

  5. #5
    Sencha User
    Join Date
    Apr 2013
    Posts
    11
    Vote Rating
    0
    Answers
    1
    metric152 is on a distinguished road

      0  

    Default A better solution

    A better solution


    After having some distance from the issue and thinking about it again I found a better way to check for the model I'm looking for.

    I created a property on the model called isContentType and set it to true. it only exists on the model I want.
    I used record.get('isContentType') and if it comes back as true then I can act on it.
    If it's undefined then I can continue on as normal. Now checking on the raw object

Thread Participants: 1

Tags for this Thread