JSON data binding not working for nested elements

36 views
Skip to first unread message

Andrew Evans

unread,
Apr 10, 2014, 12:04:31 AM4/10/14
to quick...@googlegroups.com

Hi -

I have a dialog with an address entry subform attached to a label element - like so: 

{
 
"grouped": true,
 
"title": "Add",
 
"sections": [
                 
{ "elements":[
                               
{ "type":"QLabelElement", "title":"Location",
                               
"sections": [
                                           
{
                                             
"elements": [ { "type":"QEntryElement", "title":"Address line 1","placeholder":"", "bind":"textValue:Address1", "key":"Address1"},
                                                         
{ "type":"QEntryElement", "title":"Address line 2","placeholder":"optional", "bind":"textValue:Address2", "key":"Address2"},
                                                         
{ "type":"QEntryElement", "title":"City","placeholder":"", "bind":"textValue:City", "key":"City"},
                                                         
{ "type":"QEntryElement", "title":"State/Province","placeholder":"", "bind":"textValue:StateProvRegion", "key":"Prov"},
                                                         
{ "type":"QEntryElement", "title":"ZIP/Postal Code","placeholder":"", "bind":"textValue:PostalCode", "key":"PCode"},
                                                         
{ "type":"QPickerElement", "title":"Country", "items":[["Czech Republic", "Germany", "United Kingdom"]], "value":"Czech Republic"}
                                                         
]
                                           
}
                                           
]
                               
}
                             
]
                 
}
           
]
}


I have this bound to an NSMutableDictionary as a data source.  As implemented above, the dialog displays (and the subform pushes) correctly, but it does not populate data values from the dictionary.  Now, if I "un-nest" the address form elements above (ie, move them out of the QLabelElement and up a level of hierarchy in the JSON) then suddenly all is well, and the data populates.  I'm not changing the binding, just the nesting of the elements.  Any idea why this would be?  Is there something special I have to do when binding elements that are nested under another element?  Did I do something wrong with the way I nested it?

For reference, here is the code that launches and binds, with a simplified dictionary:

    NSMutableDictionary *dataDict = [[NSMutableDictionary alloc] init];

   
[dataDict setObject:@"123 Maple Street" forKey:@"Address1"];

   
QRootElement *root = [[QRootElement alloc] initWithJSONFile:@"addjobform" andData:dataDict];

   
UINavigationController *navigation = [QuickDialogController controllerWithNavigationForRoot:root];

   
[self presentModalViewController:navigation animated:YES];



Thanks!

Andrew Evans

unread,
Apr 10, 2014, 3:54:57 PM4/10/14
to quick...@googlegroups.com
FYI, Eduardo (QD author) answered this over on Stack Overflow for me - turns out the parent element of the subform (in my case, the "Location" QLabelElement) needs to have a property added - 

"shallowBind":false - usually this defaults to true, causing binding to stop at the first level of hierarchy.  Eduardo explains that this is useful when you are hanging forms off of other forms and want to them to have different revision lifecycles.  In my simple case this is not necessary, so I'm just turning shallow binding off and it now works.

Eduardo Scoz

unread,
Apr 10, 2014, 3:57:33 PM4/10/14
to quick...@googlegroups.com
hey andrew ,glad it worked for you. I've been really busy lately, and had to stop answering most things. Apologies to others if I can't get to the answer.

For some reason, I still browse thru stackoverflow every once in a while, and it is really good at convincing me to answer stuff. Maybe the best thing would be to close this group, and keep everything there, what do you guys think?


--
-- QuickDialog site: http://escoz.com/quickdialog github: http://github.com/escoz/quickdialog.
 
You received this message because you are subscribed to the Google Groups QuickDialog group. To post to this group, send email to quick...@googlegroups.com. To unsubscribe from this group, send email to quickdialog...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/quickdialog?hl=en
---
You received this message because you are subscribed to the Google Groups "QuickDialog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to quickdialog...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages