• Radek Sulc
    September 29, 2016 at 4:05 am #2805

    Dear Gurus,

    what is the recommended pattern for updating sub-object at UI side to make the change propagated to all bound controls?

    Not sure about following way – it seems that Data control does not notice that sub-object was updated. It looks that Data control recognizes the update only at the top level.

    var owners = $(“myServiceCall”).getResult(); // The sub-object value. I need to update customer.owners with this.
    var customer = $(“customerData”).getData(); // “Pointer” to the master object.
    customer.owners = owners; // So far so good. Now let’s update the master object and propagate the change.
    $(“customerData”).setData(customer); // Nothing happens. The Data control seems to be bound to the old, unchanged copy.
    $(“customerData”).setData(fn.clone(customer)); // Rebinding to the completely new deep copy (created via JSON parse/stringify) somehow works, but why to do suchpotentially expensive operation with chained updates at many UI levels?

    As the Customer has many sub-objects we do not want to have Data control for every one which we potentially need to update. We’d like to have max one Data control and ability to update sub-object on it. We’d also like avoid enforcement of update using cloning the whole master object.

    Just a note: as in my another post – I cannot afford direct binding of the sub-object to some UI control. Need to have a temp object for some extra pre- and post- service call handling.

    I may be following a completely wrong way. Any help appreciated.

    Thanks a lot,
    Radek

    SPARK Support
    September 30, 2016 at 3:32 pm #2809

    Hi Radek,

    The work around that you mentioned using the deep copy is another technique we use when building complex custom applications.  This usually take several hours of development to get working elegantly.

    For less complicated applications, we normally just update the control itself with $(“customData/ownerControl”).setData(“owner”).  The methodology really depends on the application.

    I will take a look at using the Data Control with a BO with the Development Team on Monday.

    Regards,

    Stephen P.

    Tomáš Navrátil
    October 6, 2016 at 6:43 am #2820

    Hi Radek,

    Have you tried setting object property using set method, like I am showing below? It seems to me that it might solve your problem of data not being updated.

    $(“customerData”).getData().set(“owners”, fn.clone(owners)); // Set new property of the bound object

    Have a nice day

    Tomáš

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

Start typing and press Enter to search