Hi,
We are really struggeling to get the DataSource working the way we want it. We are building a PoC with Kendo UI Complete. We've created a ViewModel that looks like this:
The consumed class VMRoot looks like this:
The VMEntitySet is an ObservableCollection which contains VMProjectRegel objects. These are defined like so:
We have defined the Model like so:
And the DataSource like so:
The JSON we receive looks like this:
If I let the code run it results in HTML that shows the wrong Date format for the CreatedOn date. When however I specify the Model in the DataSource like so:
Now the date is shown correctly. I just don't understand why the defined Model is not seen by the DataSource and the model defenition inside the DataSource is seen.
Regards
Paul
We are really struggeling to get the DataSource working the way we want it. We are building a PoC with Kendo UI Complete. We've created a ViewModel that looks like this:
[DataContract] public partial class VMProject : VMRoot { public VMProject() {} public static VMProject GetById(object sender, int id) { return CallGetVMById<VMProject>("", id); } public static VMEntitySet<VMProject> AllVMProjectList(object sender) { return (VMEntitySet<VMProject>)CallGetVMAllList<VMEntitySet<VMProject>>(sender); } [DataMember] public String Name { get { return CallGetData<String>("Name"); } set { CallSetData ("Name", value); } } [DataMember] public VMEntitySet<VMProjectRegel> ProjectRegelList { get { return CallGetData<VMEntitySet<VMProjectRegel>>("ProjectRegelList"); } // set { CallSetData ("ProjectRegelList", value); } } }The consumed class VMRoot looks like this:
[DataContract] public partial class VMRoot : Viewmodel { public VMRoot() {} public static VMRoot GetById(object sender, int id) { return CallGetVMById<VMRoot>("", id); } public static VMEntitySet<VMRoot> AllVMRootList(object sender) { return (VMEntitySet<VMRoot>)CallGetVMAllList<VMEntitySet<VMRoot>>(sender); } [DataMember] public Int32 Id { get { return CallGetData<Int32>("Id"); } set { CallSetData ("Id", value); } } [DataMember] public DateTime CreatedOn { get { return CallGetData<DateTime>("CreatedOn"); } set { CallSetData ("CreatedOn", value); } } [DataMember] public Int32 CreatedBy { get { return CallGetData<Int32>("CreatedBy"); } set { CallSetData ("CreatedBy", value); } } [DataMember] public DateTime ChangedOn { get { return CallGetData<DateTime>("ChangedOn"); } set { CallSetData ("ChangedOn", value); } } [DataMember] public Int32 ChangedBy { get { return CallGetData<Int32>("ChangedBy"); } set { CallSetData ("ChangedBy", value); } } }The VMEntitySet is an ObservableCollection which contains VMProjectRegel objects. These are defined like so:
[DataContract] public partial class VMProjectRegel : VMRoot { public VMProjectRegel() {} public static VMProjectRegel GetById(object sender, int id) { return CallGetVMById<VMProjectRegel>("", id); } public static VMEntitySet<VMProjectRegel> AllVMProjectRegelList(object sender) { return (VMEntitySet<VMProjectRegel>)CallGetVMAllList<VMEntitySet<VMProjectRegel>>(sender); } [DataMember] public Int32 Aantal { get { return CallGetData<Int32>("Aantal"); } set { CallSetData ("Aantal", value); } } [DataMember] public Decimal Prijs { get { return CallGetData<Decimal>("Prijs"); } set { CallSetData ("Prijs", value); } } [DataMember] public Decimal BTW { get { return CallGetData<Decimal>("BTW"); } set { CallSetData ("BTW", value); } } }We have defined the Model like so:
var Project = kendo.data.Model.define({ id: "Id", fields: { DatumAanvang: { type: "date" }, DatumFaktuur: { type: "date" }, Name: { type: "string" }, CreatedOn: { "type": "date" }, CreatedBy: { "type": "number" }, ChangedOn: { "type": "date" }, ChangedBy: { "type": "number" } }});And the DataSource like so:
var dataSourceprojecten = new kendo.data.DataSource( { // the transport tells the datasource what endpoints // to use for CRUD actions schema: { model: Project }, transport: { read: { url: "../api/projectonderhoud/get", dataType: "json" } } });The JSON we receive looks like this:
[ { "DatumAanvang": "\/Date(1345732135057+0200)\/", "DatumFaktuur": "\/Date(1345732135059+0200)\/", "Name": "Project onderhoud", "ProjectRegelList": [ { "Aantal": 99, "Prijs": 99.000000000000, "BTW": 1.000000000000, "Id": 101, "CreatedOn": "\/Date(1345732135085+0200)\/", "CreatedBy": 10, "ChangedOn": "\/Date(1345732135085+0200)\/", "ChangedBy": 10 } ], "Id": 1, "CreatedOn": "\/Date(1345732135060+0200)\/", "CreatedBy": 10, "ChangedOn": "\/Date(1345732135060+0200)\/", "ChangedBy": 10 }]If I let the code run it results in HTML that shows the wrong Date format for the CreatedOn date. When however I specify the Model in the DataSource like so:
var dataSourceprojecten = new kendo.data.DataSource({ // the transport tells the datasource what endpoints // to use for CRUD actions schema: { model: { id: "Id", fields: { DatumAanvang: { type: "date" }, DatumFaktuur: { type: "date" }, Name: { type: "string" }, CreatedOn: { "type": "date" }, CreatedBy: { "type": "number" }, ChangedOn: { "type": "date" }, ChangedBy: { "type": "number" } } } }, transport: { read: { url: "../api/projectonderhoud/get", dataType: "json" } }});Now the date is shown correctly. I just don't understand why the defined Model is not seen by the DataSource and the model defenition inside the DataSource is seen.
Regards
Paul