Hi,
today i have tried to read the data out of a datasource....
i have just seen this post: http://www.kendoui.com/forums/framework/mvvm/mvvm-source-binding-to-datasource.aspx
which is bascially what i have been trying to do all day.
tho trying the answer doesn't work, when using kendo.bind($("#container"), a); it Never hits the controller action method (using MVC3) leading me to believe that the datasource never calls the server.
I have had limited success creating a datasource and calling read() on it, but could never get the data out afterwards.
what im trying to do:
1) define #view with binding templates
2) read remote datasource
3) bind that data array (from item 2) to a viewModel property (viewModel.Groups = data???)
4) bind the viewModel to the view (using
I have foudn this very hard to do...
I should say im a Noob to javascript so maybe im making a basic silly mistake... but for the life of me i can figure out what.
Thank you in advance
Rhys Walden
today i have tried to read the data out of a datasource....
i have just seen this post: http://www.kendoui.com/forums/framework/mvvm/mvvm-source-binding-to-datasource.aspx
which is bascially what i have been trying to do all day.
tho trying the answer doesn't work, when using kendo.bind($("#container"), a); it Never hits the controller action method (using MVC3) leading me to believe that the datasource never calls the server.
VIEW:
@section ViewModel
{
<
script
type
=
"text/javascript"
>
$(function () {
var a = kendo.observable({
theList: new kendo.data.DataSource({
transport: {
read: "/home/zaza",
dataType: "json",
type: "POST"
},
schema: {
model: {
id: "ID",
fields: {
ID: {
editable: false,
nullable: false
},
Name: {
editable: true,
nullable: true
}
}
}
}
})
});
kendo.bind($("#container"), a);
});
</
script
>
}
<
h2
>@ViewBag.Message</
h2
>
<
div
id
=
"container"
>
<
ul
data-role
=
"listview"
data-template
=
"ul-template"
data-bind
=
"source: theList"
>
</
ul
>
</
div
>
<
script
id
=
"ul-template"
type
=
"text/x-kendo-template"
>
<
li
>
id: <
span
data-bind
=
"text: ID"
></
span
>
name: <
span
data-bind
=
"text: Name"
></
span
>
</
li
>
</
script
>
HOME - CONTROLLER:
public class Place
{
public int ID { get; set; }
public string Name { get; set; }
}
[HttpPost]
public JsonResult zaza()
{
List<
Place
> plases = new List<
Place
>();
plases.Add(new Place() { ID = 0, Name = "Larocque" });
plases.Add(new Place() { ID = 1, Name = "St-Louis" });
plases.Add(new Place() { ID = 2, Name = "Dorval" });
plases.Add(new Place() { ID = 3, Name = "St-Pierre" });
return Json(plases, JsonRequestBehavior.DenyGet);
}
I have had limited success creating a datasource and calling read() on it, but could never get the data out afterwards.
what im trying to do:
1) define #view with binding templates
2) read remote datasource
3) bind that data array (from item 2) to a viewModel property (viewModel.Groups = data???)
4) bind the viewModel to the view (using
kendo.bind($("#view"), viewModel);)
I have foudn this very hard to do...
I should say im a Noob to javascript so maybe im making a basic silly mistake... but for the life of me i can figure out what.
Thank you in advance
Rhys Walden