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

Important MVVM Binding Issue With Fiddle Example

4 Answers 96 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 06 Oct 2012, 09:47 PM
The issue is simple.  Without uncommenting the code that you will notice in the fiddle, binding to a viewmodel (kendo.observable) that contains a kendo.data.DataSource simply fails.  

http://jsfiddle.net/dotBomb/PMXWU/

Why?

Form binding clearly doesn't work the same way as kendoGrid binding, which I have working using a kendo.data.DataSource.  Seriously frustrating.  Not to mention when I wire this up to a transport with URLs, trying to sync the datasource via the sync() method, after editing data, fails miserably.  

Note: the collective opinion on the kendo web ui forums is that anything other than the simplest of scenarios usually fails.  I share this opinion.  

Dan


4 Answers, 1 is accepted

Sort by
0
Martin
Top achievements
Rank 1
answered on 09 Nov 2012, 03:23 PM
What am I missing in the jsfiddle? When I update the text inputs, the spans also change. Tested in Firefox and IE 8. I didn't uncomment the commented-out code.
0
Daniel
Top achievements
Rank 1
answered on 09 Nov 2012, 03:35 PM
Martin,

The problem arises when you just visit the fiddle page.  You don't even have to interact with it.  Look at the transport object within the kendo.data.DataSource object.  Binding is already wired up to the localData object but nothing is displayed.  Everything else is in place for binding to occur naturally, and according to the documentation, this scenario should be supported but clearly it's not.

Dan
0
Accepted
Martin
Top achievements
Rank 1
answered on 09 Nov 2012, 04:27 PM
Ahh, I didn't see that there were initial values that were not being displayed. Thanks!

I think the problem you are having is that dataSource.DataPoint1 is undefined.
I was able to get this scenario working here: http://jsfiddle.net/PMXWU/4/

Firstly, I called datasource.read() before setting up the viewModel.
Secondly, I bound the viewModel to the dataSource results:
var viewModel = kendo.observable({
    ds: dataSource.data()[0]
}
Does that help?
0
Daniel
Top achievements
Rank 1
answered on 09 Nov 2012, 04:33 PM
Martin,

The solution you have provided definitely works for me with no issue.  Kudos, and thank you.

Dan
Tags
MVVM
Asked by
Daniel
Top achievements
Rank 1
Answers by
Martin
Top achievements
Rank 1
Daniel
Top achievements
Rank 1
Share this question
or