1. #1
    Ext JS Premium Member
    Join Date
    Mar 2011
    Posts
    33
    Answers
    1
    Vote Rating
    0
    jtiai is on a distinguished road

      0  

    Default Unanswered: ExtJS 4, related models and forms

    Unanswered: ExtJS 4, related models and forms


    I would like to create a form that can be used to edit hierarchical data.

    If I have for example following data:
    Code:
    { "name" :  "foo",
       "somedata" : 123,
       "extrainfo" : {
                                 "name" : "bar",
                                 "otherdata": 888
                             }
    }
    And I would like to have a form that contains fields for: "name", "somedata", "extrainfo.name" and "extrainfo.otherdata". And preferably so that I can set/get values by using loadRecord and getRecord methods on a form.

    Closest thing I managed to make was to add fields as "extrainfo.name" (exactly like that) in the mian model but that kind of destroys the idea of using two models with properly set relation(s).

  2. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,605
    Answers
    543
    Vote Rating
    326
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      0  

    Default


    I may be way off here, but my understanding of the ExtJS model relationships is that there is not proper support for 1-1 relationships, only 1-many. In the context of a 1-many relationship the idea of populating a form doesn't really make sense as far as I can tell. I think the 'correct' way to do this is to merge your 2 models into 1.

    Like I said, I might be completely wrong. I've seen a lot of people ask effectively the same question over the last few weeks (usually trying to populate a grid rather than a form) but I've not seen anyone give a working solution that used multiple models.

  3. #3
    Ext JS Premium Member
    Join Date
    Mar 2011
    Posts
    33
    Answers
    1
    Vote Rating
    0
    jtiai is on a distinguished road

      0  

    Default


    Since one to one relation is basically special case of one to many that shouldn't affect outcome.

    More over I probably would like to have form that could contain also multiple entries from child records.

    Grids are pretty simple since they require store where data is and related entries do have stores.

    With 4.0.2a you can do grid.bindStore(mymodel.somerelation()) (There is a bug that is fixed in 4.0.3 in grid.reconfigure that would be better option.)

    It would be useful to have way to define form fields with hierarchy so that even using "form.getValues()" would return hierarchical data.

    Like if I define field name like "myobj.id" form.getValues() would interpret that as a

    Code:
    { "myobj" : { "id" :  value }}

Thread Participants: 1