Hello,
I'm trying to user the kendo.data.Model to make an observable object from a single object retrieved from a web service.
When I do a kendo.data.Model.define(...), the fields are entirely ignored, and the field containing the date is mapped to a string.
If I create a datasource with the exact same model, I retrieve a correct date.
I tried to put a custom parse function, and in the first case, nothing happen.
In the second scenario, I can see my parse method called.
Here is a sample of what I do :
This make the following output to the console :
Thanks for you help.
I'm trying to user the kendo.data.Model to make an observable object from a single object retrieved from a web service.
When I do a kendo.data.Model.define(...), the fields are entirely ignored, and the field containing the date is mapped to a string.
If I create a datasource with the exact same model, I retrieve a correct date.
I tried to put a custom parse function, and in the first case, nothing happen.
In the second scenario, I can see my parse method called.
Here is a sample of what I do :
var
obj = {
Id:
"1"
,
Name:
"foo"
,
Age:
"28"
,
Fire:
"/Date(1348479856993)/"
};
var
objModel = kendo.data.Model.define({
id:
"Id"
,
fields: {
Id: { type:
"number"
},
Name: { type:
"string"
, parse:
function
(e) {
debugger;
return
e;
}
},
Fire: { type:
"date"
},
Age: { type:
"number"
}
}
});
var
obj1 =
new
objModel(obj);
console.log(obj1.get(
"Fire"
));
var
dataSource =
new
kendo.data.DataSource({
data: [ obj ],
schema: {
model: {
id:
"Id"
,
fields: {
Id: { type:
"number"
},
Name: { type:
"string"
, parse:
function
(e) {
debugger;
return
e;
}
},
Fire: { type:
"date"
},
Age: { type:
"number"
}
}
}
}
});
dataSource.read();
var
obj2 = dataSource.at(0);
console.log(obj2.get(
"Fire"
));
/Date(1348479856993)/
Mon Sep 24 2012 11:44:16 GMT+0200 (Romance Daylight Time)
Thanks for you help.