Hi,
According to DataSource Transport API, I am using the following code for my transport:
I am having a very strange problem with this options.success function. my json object from the ajax response looks like this
options.success() has no problem to parse it. However, if i want to do some reformatting by creating a separate object historyData, i will have an error from options.success() saying TypeError: Cannot call method 'slice' of undefined, unless i name the array property of historyData - rows.
it almost feels like the DataSource options.success() function is expecting an array called rows. it was pure coincident that my original json contains this rows property.
can anyone help to explain whether my finding is true? and what exactly is this options parameter? there is no document about it.
Thanks
amp
According to DataSource Transport API, I am using the following code for my transport:
01.
var
historyTransport = {
02.
read:
function
(options) {
03.
$.ajax({
04.
url:
"../../AppData/Batch/History.json"
,
05.
dataType:
"json"
,
06.
success:
function
(response) {
07.
// notify the data source that the request succeeded
08.
console.log(
'successfully load History.json'
);
09.
var
rows = [];
10.
$.map(response.rows,
function
(n,i) {
11.
var
obj = { status: n.cell[0] };
12.
rows.push(obj);
13.
14.
});
15.
var
historyData = {};
16.
historyData.rows = rows;
17.
options.success(historyData);
18.
19.
},
20.
error:
function
(response) {
21.
// notify the data source that the request failed
22.
console.log(
'failed to load History.json'
);
23.
}
24.
});
25.
}
26.
}
Object {rows: Array[7675], page: 1, total: 1, records:
"1"
}
it almost feels like the DataSource options.success() function is expecting an array called rows. it was pure coincident that my original json contains this rows property.
can anyone help to explain whether my finding is true? and what exactly is this options parameter? there is no document about it.
Thanks
amp