Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aurelia binding and KendoUI SDK missing API #7

Open
adriatic opened this issue Aug 6, 2017 · 0 comments
Open

Aurelia binding and KendoUI SDK missing API #7

adriatic opened this issue Aug 6, 2017 · 0 comments

Comments

@adriatic
Copy link
Member

adriatic commented Aug 6, 2017

Two way binding

Let's just begin by saying that with plain Kendo controls it's not possible to have two-way databinding at all. We build a value-binding feature that allows you to two-way databind the value property and it uses the value() function of the Kendo control to tell it to update the value. So this is not "real" two-way databinding, but from a user perspective it would seem as shown in this: example.

The datasource is also a bit unique. You can bind the datasource property of a control to a plain javascript object like we do here. Kendo's combobox is getting this javascript object and wraps it into a datasource class instance. The original reference to the datasource is lost, so if you update a property in there it will not be noticed by the control. Wrapping the plain javascript object into a new kendo.data.DataSource() is one of the solutions you may consider:

datasource = new kendo.data.DataSource({
	transport: {
		read: function(options) {
			return System.import('samples/chart/area-charts/json/spain-electricity.json!json')
			.then(data => options.success(data));
		}
	},
	sort: {
		field: 'year',
		dir: 'asc'
	}
});

That way Kendo's control wont wrap the datasource into a a kendo.data.DataSource instance again, but it will just use the original instance (call by reference is used instead of call by value with plain javascript objects). So if you use kendo.data.DataSource instead of the plain javascript object, so you should be able to bind a single datasource to multiple controls.

In all other cases you'd need to either use functions like enable(), setOptions() or even our recreate() function to tell the control to pick up the changed value

Note: Some Kendo controls have functions like setOptions() or setDataSource() that allow you to change an option of the Kendo control without having to destroy and recreate it. As one of the alternative solutions, we would like to see all Kendo controls have such functions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant