1. #1
    Sencha Premium Member mik3e's Avatar
    Join Date
    Jan 2012
    Location
    Vienna / Austria
    Posts
    81
    Vote Rating
    1
    mik3e is on a distinguished road

      0  

    Default Unanswered: Display 1:1 relation between models in a Grid / Associations

    Unanswered: Display 1:1 relation between models in a Grid / Associations


    Hi there,

    I´m trying to display a 1:1 relation between two models in a grid (one row). Here´s the problem I´m trying to solve:

    The problem:
    Code:
    Model 1: Credential (Login data for a character - password + email)
    Proxy: REST
    
    Model 2: Character (Data of a human being - firstName + lastName)
    Proxy: REST
    Now in the backend we need a Grid view called "User" which shows all users of the system in a list. A User is a join of a Character and a Credential and doesn´t physically exists in the data model.

    What I want to get:
    Code:
    ExtJS Grid with the following content:
    -------------------------------------------------
    1    FirstName    LastName    email    password
    -------------------------------------------------
    2    FirstName    LastName    email    password
    -------------------------------------------------
    3    FirstName    LastName    email    password
    So as you see I want to get a "User" list which is generated with ExtJS mixed up of credentials and characters.

    Of course you could say: "Hey, just implement a http://domain.com/User REST interface on you server side which does the work for you". That´s correct, but I want to have a look if there is a convenient way to show the data on the client side.

    I already tried different solutions with hasMany and belongsTo and read many articles in the forum, but I didn´t find a solution for that till now.

    Thanks for any ideas,
    Ciao,
    Mike

  2. #2
    Ext JS Premium Member tvanzoelen's Avatar
    Join Date
    Apr 2008
    Location
    Groningen - Netherlands
    Posts
    1,118
    Vote Rating
    30
    Answers
    85
    tvanzoelen has a spectacular aura about tvanzoelen has a spectacular aura about tvanzoelen has a spectacular aura about

      0  

    Default


    I think that associating thing with models isn't much evolved yet. What I know about it is that you define a grid with the usermodel behind it.

    You define four columns (two extra for the credentials) in the grid. In the columnrenderers for the credentials, you lookup the values in the credential model and display it with code in these columnrenderers.

  3. #3
    Sencha Premium Member mik3e's Avatar
    Join Date
    Jan 2012
    Location
    Vienna / Austria
    Posts
    81
    Vote Rating
    1
    mik3e is on a distinguished road

      0  

    Default


    Uh.. that breaks the sense of usage a bit. So it would be really better to implement a user object on the server side ...

  4. #4
    Sencha Premium Member mik3e's Avatar
    Join Date
    Jan 2012
    Location
    Vienna / Austria
    Posts
    81
    Vote Rating
    1
    mik3e is on a distinguished road

      0  

    Default


    Hm, on the other side the "virtual" user object on server side is also not a nice solution. Cause as the REST standard defines, each URL represents a "real" ressource - and user is not a real ressource in the system.

    So I´ll try the way you´ve suggested first...

  5. #5
    Ext JS Premium Member tvanzoelen's Avatar
    Join Date
    Apr 2008
    Location
    Groningen - Netherlands
    Posts
    1,118
    Vote Rating
    30
    Answers
    85
    tvanzoelen has a spectacular aura about tvanzoelen has a spectacular aura about tvanzoelen has a spectacular aura about

      0  

    Default


    Sorry, Its a bit different as I said. You put the user model under the grid. So no extra columns for the credentials but for the columns of the foreignkey in the usermodel you add a columnrenderer that looks up the associated value in the credentialsmodel.

    See http://www.sencha.com/forum/showthre...el-association

Thread Participants: 1

Tags for this Thread