This is a migrated thread and some comments may be shown as answers.

Multiple binders precedence

4 Answers 63 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
Pascal
Top achievements
Rank 1
Pascal asked on 28 Oct 2016, 12:09 PM

Hello,
We would like to know how to configure kendo for a given model binder to be the last of all the binders executed when a property is bound to multiple custom binders ?

E.g.:

<div data-bind="customBinder1:someAction, enabled:someOtherAction, customBinder2:anotherAction, value:someProperty"></div>

How to ensure customBinder2 will ALWAYS be the last one to refresh the dom element state ?

 

Regards,

4 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 01 Nov 2016, 08:09 AM
Hello Pascal,

The binding order in MVVM cannot be specified, which is MVVM specific and the Kendo UI team has no control over it.

If you share more details for the scenario, we can investigate if there is another approach which can be used to achieve the desired result.

Regards,
Stefan
Telerik by Progress
 
Build rich, delightful, *native* Angular 2 apps with Kendo UI for Angular 2. Try it out today! Kendo UI for Angular 2 (currently in beta) is a jQuery-free toolset, written in TypeScript, designed from the ground up to offer true, native Angular 2 components.
 
0
Pascal
Top achievements
Rank 1
answered on 03 Nov 2016, 10:01 AM

Hello Stefan,
Thank you for your help.
Our scenario is that we would like to enable/disable widgets based on presence of given permissions in the model.

To do so we want to centralize the logic in a custom permissions binder.
If this binder is not the last to be executed we can go into troubles because there is another binder enabling/disabling widgets based on model state in addition to the model itself (which have custom methods plugged either to enable or disable binding)

 

Let say we have the following markup:

 

<div role="button" data-bind="enable:EnableButtonIfReadyForNextStep, permissions:{Roles:'A,D', Edit:'B,C'}"></div>

Our idea is to have the following execution order :
 1) EnableButtonIfReadyForNextStep is executed to enable or disable or button
 2) Another binder not explicitely mentionned in the button markup may be run to deactivate the button
 3) Lastly, our permissions binder will run to deactivate the button if it is enabled and does not have any of the edit role in its roles.

- If EnableButtonIfReadyForNextStep  runs after permissions binder has disabled widget it's not correct.
- If our other binder not mentionned in the markup enable the widget after the permissions binder it's not correct either.

0
Accepted
Stefan
Telerik team
answered on 07 Nov 2016, 09:14 AM
Hello Pascal,

After testing the different custom binders and inspecting the implementation, I can confirm that the order of the custom binders depends on the order in which they are set.

Please check the following example using three custom binders and noticed that changing the order in which they are set will also change the order in which they are bound:

http://dojo.telerik.com/AzUgi

I hope this will help to achieve the desired result and ensure the desired order.

Regards,
Stefan
Telerik by Progress
 
Build rich, delightful, *native* Angular 2 apps with Kendo UI for Angular 2. Try it out today! Kendo UI for Angular 2 (currently in beta) is a jQuery-free toolset, written in TypeScript, designed from the ground up to offer true, native Angular 2 components.
 
0
Pascal
Top achievements
Rank 1
answered on 07 Nov 2016, 12:40 PM
Hello Stefan,
I came to the same conclusion by digging in the sources.

Yes this help achieving the desired result.
Anyway thank you for your help.

Regards,
Tags
MVVM
Asked by
Pascal
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Pascal
Top achievements
Rank 1
Share this question
or