Results 1 to 5 of 5

Thread: Associated Models in Batch

  1. #1
    Sencha User
    Join Date
    Nov 2010
    Location
    Canton, GA, USA
    Posts
    164
    Answers
    4

    Default Answered: Associated Models in Batch

    I've been tinkering with the Isolated Child Session example in 6.5.3 after implementing something similar in my own code and running into a problem. In that example, I click the Edit button to open the first Company, then Add Order, then Save. The resulting Changes looks like so:

    Code:
    {
        "Order": {
            "C": [
                {
                    "date": "2018-05-03",
                    "shipped": false,
                    "id": "Order-1",
                    "quantity": 0,
                    "companyId": 1
                }
            ]
        }
    }
    How did the "companyId" property get set? I'm doing something similar (seemingly identical) but that parent ID isn't getting set. What logic is setting it in that example?

  2. Figured it out. I had to remove the "id" property in the Base model as mentioned before but I also needed to remove the "type" from reference fields. I assume this lets them revert to "auto" so the temporary IDs like "Company-1" and the actual integer IDs from the server are both allowed.

  3. #2
    Sencha User
    Join Date
    Nov 2010
    Location
    Canton, GA, USA
    Posts
    164
    Answers
    4

    Default

    Actually, my testing of my own code is equivalent to creating both a new Company and an Order which in the example yields Changes like so:

    Code:
    {
        "Company": {
            "C": [
                {
                    "id": "Company-1",
                    "phone": "800-555-1212",
                    "price": 0,
                    "priceChange": 0,
                    "priceChangePct": 0,
                    "priceLastChange": null,
                    "rating": 0,
                    "name": "TEST"
                }
            ]
        },
        "Order": {
            "C": [
                {
                    "date": "2018-05-03",
                    "shipped": false,
                    "id": "Order-1",
                    "quantity": 0,
                    "companyId": "Company-1"
                }
            ]
        }
    }
    Still not sure where the new Order's "companyId" value comes from. I'm getting null there in my code.

  4. #3
    Sencha User
    Join Date
    Nov 2010
    Location
    Canton, GA, USA
    Posts
    164
    Answers
    4

    Default

    I wonder if this is due to my models having an integer ID field and the temporary ID for the phantom records being strings.

  5. #4
    Sencha User
    Join Date
    Nov 2010
    Location
    Canton, GA, USA
    Posts
    164
    Answers
    4

    Default

    Removed the explicitly defined id field from my Base model but I'm getting the same results. Sigh... Anyone?

  6. #5
    Sencha User
    Join Date
    Nov 2010
    Location
    Canton, GA, USA
    Posts
    164
    Answers
    4

    Default

    Figured it out. I had to remove the "id" property in the Base model as mentioned before but I also needed to remove the "type" from reference fields. I assume this lets them revert to "auto" so the temporary IDs like "Company-1" and the actual integer IDs from the server are both allowed.

Similar Threads

  1. Saving association models using Batch
    By marius.s in forum Ext 5: Q&A
    Replies: 1
    Last Post: 4 Jul 2014, 1:44 AM
  2. Replies: 1
    Last Post: 9 May 2014, 4:49 PM
  3. array of models or arrays in models?
    By spoggle in forum Sencha Touch 2.x: Q&A
    Replies: 1
    Last Post: 13 Dec 2013, 4:23 PM
  4. Replies: 2
    Last Post: 27 Sep 2012, 9:07 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •