Results 1 to 4 of 4

Thread: Model with nested hasmany, empties child record on model.load(

  1. #1
    Sencha Premium Member
    Join Date
    Apr 2011
    Posts
    22
    Answers
    1
    Vote Rating
    0
      0  

    Default Unanswered: Model with nested hasmany, empties child record on model.load(

    Hi There,

    I've got an json file looking like so (snippet):
    Code:
    {
    
    • Key: 1,
    • Type: 1,
    • Description: "Cell 1",
    • Cell_Assignment: {
      • Product_Name: "Aardappelen",
      • Product_Tag: "potatoes",
      • Description: null
      },
    • Node_ID: "C44619BB298F",
    • Function_Assignments: [
      • {
        • Function: {
          • Key: 60001,
          • Tag: "mProdTemp1",
          • Name: "mProdTemp1"
          },
        • Type: 1,
        • Value: 0,
        • Set_By: "-1",
        • Set_Prio: -1,
        • DashboardVisible: true
        },
      • {
        • Function: {
          • Key: 60002,
          • Tag: "mProdTemp2",
          • Name: "mProdTemp2"
          },
        • Type: 0,
        • Value: 0,
        • Set_By: "-1",
        • Set_Prio: -1,
        • DashboardVisible: true
        },
    Parent record is called: ' Cell', and has an HasMany association with FunctionAssignments, wich on its turn has an HasOne association with Function.

    All works great, but now i want to refresh one specific record, so i started like so:

    Code:
    var cell = Ext.ModelMgr.getModel('EasyStoreApp.model.Cell');
    cell.load(this.getData().get('Key'),{
        success: function(loaded_cell) {
        
          console.log(loaded_cell);
          console.log(loaded_cell.FunctionAssignments().load());
          
          loaded_cell.FunctionAssignments().each(function(functionassignment) {
    
    
              var func = functionassignment.getFunction();
            console.log(func.get('Tag') + ':' + functionassignment.get('Value') + ':' + func.get('Error'));
    
    
          });
                                                 
        }
    });
    The parent record gets loaded, but the child records (array) is emptied, and not refilled. When i would choose to not run this load() command on the HasMany association:

    Code:
    loaded_cell.FunctionAssignments().load()
    It remains filled, but not with the newly retrieved values.

    Is there something to be done differently ?

    Regards,

  2. #2
    Sencha Premium Member
    Join Date
    Apr 2011
    Posts
    22
    Answers
    1
    Vote Rating
    0
      0  

    Default

    anybody ?

  3. #3
    Sencha Premium Member
    Join Date
    Apr 2011
    Posts
    22
    Answers
    1
    Vote Rating
    0
      0  

    Default

    Another thing i found out: when i just reload the store in its total with store.load(); , then the 'HasMany' records are not reloaded either!

    So from where im standing it looks like it only goes right, when the store gets loaded for the first time by the autoLoad property.

    Maybe that will clear things up a little ?

  4. #4
    Sencha Premium Member
    Join Date
    Apr 2011
    Posts
    22
    Answers
    1
    Vote Rating
    0
      0  

    Thumbs up Solved

    This problem was solved, by sticking to a earlier version of Sencha Touch 2. The latest version of Sencha Touch still has this problem...

Tags for this Thread

Posting Permissions

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