Binding/Update view elements from model objects?

55 views
Skip to first unread message

Robert La Ferla

unread,
Jun 5, 2014, 12:56:11 PM6/5/14
to quick...@googlegroups.com
So I have a bunch of QEntryElements for various attributes on my model object.  Is there a way to update the elements from the model when the model values change?

Eduardo Scoz

unread,
Jun 5, 2014, 1:04:04 PM6/5/14
to quick...@googlegroups.com
Not automatically, you have to call the binding methods manually, or implement the onChange blocks and call the method yourself.

I played with two way automatic binding in the past, but never got it to look good enough to be useful. 


On Thu, Jun 5, 2014 at 9:56 AM, Robert La Ferla <omsr...@gmail.com> wrote:
So I have a bunch of QEntryElements for various attributes on my model object.  Is there a way to update the elements from the model when the model values change?

--
-- 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.

Robert La Ferla

unread,
Jun 5, 2014, 1:07:57 PM6/5/14
to quick...@googlegroups.com
How do you update an element?  I tried  element.value = newvalue but it didn't reflect in the ui.  I also tried adding 

            [[QuickDialogController controllerForRoot:root].quickDialogTableView reloadData]; to force a refresh but that didn't work.  Code snipped please...

Eduardo Scoz

unread,
Jun 5, 2014, 1:21:18 PM6/5/14
to quick...@googlegroups.com
reloading all data after your element is set should work. There are also custom methods in the controller to update cells for specific elements directly.


On Thu, Jun 5, 2014 at 10:07 AM, Robert La Ferla <omsr...@gmail.com> wrote:
How do you update an element?  I tried  element.value = newvalue but it didn't reflect in the ui.  I also tried adding 

            [[QuickDialogController controllerForRoot:root].quickDialogTableView reloadData]; to force a refresh but that didn't work.  Code snipped please...

--

Robert La Ferla

unread,
Jun 5, 2014, 1:31:30 PM6/5/14
to quick...@googlegroups.com
It doesn't seem to work.  Which custom methods specifically?

Robert La Ferla

unread,
Jun 5, 2014, 2:48:20 PM6/5/14
to quick...@googlegroups.com
Eduardo,

I still can't get it to work.

QuickDialogController * qdc; // the dialog controller

QEntryElement * myElement; // this is later initialized, displayed, etc...

    qdc = [QuickDialogController controllerForRoot:root];

    UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:qdc];

    [self presentViewController:navigation animated:NO completion:^{ // etc... }];

then elsewhere in the code AFTER the dialog is displayed, I update the value of the element BUT the new value is never displayed.

   myElement.value = @"updated value";

    [qdc.quickDialogTableView reloadData];

I also tried:

[qdc.quickDialogTableView reloadCellForElements:myElement, nil];


Eduardo Scoz

unread,
Jun 5, 2014, 2:50:07 PM6/5/14
to quick...@googlegroups.com
strange it doesn't work, those are the proper methods. Have you tried running the sample code to see if that works?


Robert La Ferla

unread,
Jun 5, 2014, 3:22:49 PM6/5/14
to quick...@googlegroups.com
Well I have two root elements.  The main one and one that is for a subform.  The subform root element is added to the main root element.  I'm trying to update a field on the subform.  However, I think I tried updating a field on the main form and it didn't work either.

Eduardo Scoz

unread,
Jun 5, 2014, 3:25:22 PM6/5/14
to quick...@googlegroups.com
when you refresh the table view , only the currently visible tableView gets refreshed. Items in a subview controller that is not appearing won't update, obviously. Maybe your'e calling refresh on the wrong tableview?

Robert La Ferla

unread,
Jun 5, 2014, 4:40:13 PM6/5/14
to quick...@googlegroups.com

I tried this but it doesn't work.  I suppose that it could be because I'm not getting the right controller for the sub menu.  How would I get it?

    [[QuickDialogController controllerForRoot:root].quickDialogTableView reloadData];

    [[QuickDialogController controllerForRoot:subMenuRoot].quickDialogTableView reloadData];

Eduardo Scoz

unread,
Jun 5, 2014, 4:47:03 PM6/5/14
to quick...@googlegroups.com
controllerForRoot recreates a new view controller, that's now how you should use it. 

You should keep a reference to the controller, or use inheritance to execute the code at the appropriate time. Take a look at how the sample app does it.


Robert La Ferla

unread,
Jun 5, 2014, 4:52:52 PM6/5/14
to quick...@googlegroups.com
So the actual problem is that I was setting "value" instead of "textValue".  This is before the submenu is presented so setting "textValue" works.   However, I suspect that if I set "textValue" AFTER the submenu is displayed, I will need to refresh the table view.  I do keep a reference to the main root controller.  I do not see how it's even possible to get at the table view for a submenu controller because the API dynamically creates a controller instance as needed and I don't see a method to get it.  Is there one?

Robert La Ferla

unread,
Jun 5, 2014, 4:55:12 PM6/5/14
to quick...@googlegroups.com
I just did more testing and all I needed to do was set the textValue.  No refresh of either table was necessary!
Reply all
Reply to author
Forward
0 new messages