Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 84751

my datasource is my model...

$
0
0

Hi there,

 I need some help with the "conversion" of a datasource into a view model.

I made a simple page for test and I started it with some local JSON, the page is the following one:

<div id="mvvm">

<span data-bind="text: title"></span>

<div id="chart" data-role="chart" data-bind="source: dsChart" ....... />

</div>

<script>

var view  = kendo.observable({ title: "TEST", dsChart: [{ Name: "John", Surname: "West" }] });

kendo.bind($("#mvvm"), view); 

</script>

This worked just fine. After it I decide to move on and bind the view with remote data from a WCF application. The application returns exactly the same JSON I wrote in the view: { title: "TEST", dsChart: [{ Name: "John", Surname: "West" }]

So I added the remote datasource in the code:

var view  = kendo.observable({ model: new kendo.data.DataSource({ transport: { read: { data: "http....", dataType: "json" }}}});

when I did this the application stopped working, so I tried to change kendo.bind like I saw in some post here:

kendo.bind($("#mvvm"), view.model); 

kendo.bind($("#mvvm"), view.model.view()); 

kendo.bind($("#mvvm"), view.model.view()[0]); 

Of course none of this code worked... Would you please help me understand what I'm doing wrong here. This is just a simple test, but what I'm trying to do is to get all the data ( labels, texts, styles, datasource for grids and charts ) as JSON from web service and build the page with view model.

Thanks

 

 
 
 
 
 

Viewing all articles
Browse latest Browse all 84751


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>