We are considering about using kendo UI in our project. Here i came up with some problems:
As you see, from JSON.stringify(product), I get some Kendo added cruft like _events and change and length. On top of this, the value of UnitPrice has been converted to a dictionary/json object instead of its original array. What I really need is to obtain the original data structure for that row.
Reason for such a need is because we are using CouchDB and we really need the data structure to remain the same and not have KendoUI Grid convert it to something else.
Thank you in advance!
$(
"#grid"
).kendoGrid({
dataSource: {
data:[
{
"ProductID"
:
"1"
,
"ProductName"
:
"name01"
,
"UnitPrice"
: [
'$33.55'
,
'$55.55'
,
'$23.55'
]},
{
"ProductID"
:
"2"
,
"ProductName"
:
"name02"
,
"UnitPrice"
: [
'xx'
,
'yy'
,
'zz'
]},
{
"ProductID"
:
"3"
,
"ProductName"
:
"name03"
,
"UnitPrice"
: [
'aa'
,
'bb'
,
'cc'
]}
]
},
selectable:
"row"
,
columns: [
"ProductID"
,
"ProductName"
,
"UnitPrice"
],
dataBound:
function
(){
$(
"#select"
).bind(
"click"
,
function
(){
var
$row = $(
"#grid"
).data(
"kendoGrid"
).select();
var
product = $(
"#grid"
).data(
"kendoGrid"
).dataItem($row).toJSON();
alert(JSON.stringify(product));
//what i got from alert is:
/*
{"ProductID":"1",
"ProductName":"name01",
"UnitPrice":{
"0":"$33.55",
"1":"$55.55",
"2":"$23.55",
"_events": {"change":[null]},"length":3}}
*/
});
}
});
As you see, from JSON.stringify(product), I get some Kendo added cruft like _events and change and length. On top of this, the value of UnitPrice has been converted to a dictionary/json object instead of its original array. What I really need is to obtain the original data structure for that row.
Reason for such a need is because we are using CouchDB and we really need the data structure to remain the same and not have KendoUI Grid convert it to something else.
Thank you in advance!