This is a migrated thread and some comments may be shown as answers.

json datasource

1 Answer 111 Views
Grid
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 23 Feb 2015, 06:50 PM
Hi,
I initially tested with a json result returned from a firebird database and my grid worked fine. Today I'm testing with a json result from a mongdb database and I can't populate the grid's datasource. Since I'm using json not sure what problem could be. See error below. The result json looks like


[{Fname: "Nataly",Lname: "1Nataly",Age: 9,Gender: "female",Throwing: 0,ThrowRating: 4,Hitting: 1,HitRating: 21,Fielding: 1,FieldRating: 44,Catch: 5,CatchRating: 17,Running: 1,TotalScore: "",Bdate: "2/1/2007",ZipCode: "12345-4567",Flagged: "No",Coach: "",ThrowSub1: 0,ThrowSub2: 8,HitSub1: 10,HitSub2: 42,FieldSub1: 10,FieldSub2: 88,CatchSub1: 50,CatchSub2: 34,RunTotal: 10,ThrowTotal: "8.40",CatchTotal: "84.84",PlayerTotal: "264.08",HitTotal: "53.04",FieldTotal: "107.80",id: "54c3b6ffc2ea084d20e45fe5"},...]
and my code
$scope.gridOptions = {
height: 700,
selectable: true,
scrollable: true,
pageable: true,
reorderable: true,
resizable: true,
groupable: true,
sortable: {
mode: "multiple",
allowUnsort: true
},
navigatable: true,
filterable: {
extra: false,
operators: {
string: {
startswith: "Starts with",
eq: "Is equal to",
neq: "Is not equal to"
}
}
},
toolbar: ["excel"],
excel: {
allPages: true
},
filterable: {
mode: "row"
},
columnMenu: true,
pageable: {
refresh: true,
pageSizes: true,
buttonCount: 5,
pageSize: 10,
pageSizes: [10, 25, 50, 100]
},
columns: [

{command: ["edit"], title: " ", locked: true, width: "80px"},
{
field: "id", title: "id", locked: true, width: 170,
lockable: false, filterable: {cell: {operator: "startswith"}}
},

{field: "Bdate", title: "Bdate", width: 200, locked: false, format: "{0:MM/dd/yyyy}"},
{field: "Gender", title: "Gender", width: 150, filterable: {cell: {operator: "contains"}}},
{field: "Lname", title: "Lname", width: 150, filterable: {cell: {operator: "contains"}}},
{field: "Fname", title: "Fname", width: 150, filterable: {cell: {operator: "contains"}}},
{field: "Age:", width: 300, title: "Age:", filterable: {cell: {operator: "eq"}}}

],
editable: "popup",
dataSource: {
type: "json",
transport: {
read: function (e) {
PlayerModel.getAllPlayers($scope.form).then(function (data) {
console.log('read kendo init1 ', data)
e.success(data);
});
}
,
update: function (e) {
console.log(' update kendo e.success(data) ', e, e.data.models[0].CLAIM_NO);// e.success(data))
PlayerModel.update(e);
e.success();
}

},

batch: true,
schema: {
model: {
id: "id" ,
fields: {
id: {type: "string"},
Bdate: {type: "date"},
Fname: {type: "string"},
Lname: {type: "string"},
Age: {type: "string"},
Gender: {type: "string"},
Throwing: {type: "integer"},
ThrowRating: {type: "integer"},
Hitting: {type: "integer"},
Fielding: {type: "integer"},
FieldRating: {type: "integer"},
Catch: {type: "integer"},
CatchRating: {type: "integer"},
Running: {type: "integer"},
TotalScore: {type: "integer"},
ThrowSub1: {type: "integer"},
ThrowSub2: {type: "integer"},
HitSub1: {type: "integer"},
HitSub2: {type: "integer"},
FieldSub1: {type: "integer"},
FieldSub2: {type: "integer"},
CatchSub1: {type: "integer"},
CatchSub2: {type: "integer"},
RunTotal: {type: "integer"},
ThrowTotal: {type: "integer"},
CatchTotal: {type: "integer"},
HitTotal: {type: "integer"},
RunTotal: {type: "integer"},
PlayerTotal: {type: "integer"}
}
}
},
pageSize: 10
}
}
==============================================================================================
SyntaxError: Unexpected token :
    at Function (native)
    at Object.mt.getter (http://localhost:8015/bower_components/Kendo/kendo.all.min.js:9:29454)
    at r (http://localhost:8015/bower_components/Kendo/kendo.all.min.js:39:4138)
    at l.extend.initSuggestDataSource (http://localhost:8015/bower_components/Kendo/kendo.all.min.js:39:7341)
    at new l.extend.init (http://localhost:8015/bower_components/Kendo/kendo.all.min.js:39:5265)
    at HTMLSpanElement.<anonymous> (http://localhost:8015/bower_components/Kendo/kendo.all.min.js:10:2314)
    at Function.b.extend.each (http://localhost:8015/bower_components/Kendo/jquery.min.js:3:5257)
    at A.b.fn.b.each (http://localhost:8015/bower_components/Kendo/jquery.min.js:3:2013)
    at A.mt.plugin.e.fn.(anonymous function) [as kendoFilterCell] (http://localhost:8015/bower_components/Kendo/kendo.all.min.js:10:2298)
    at pt.ui.DataBoundWidget.extend._filterRow (http://localhost:8015/bower_components/Kendo/kendo.all.min.js:30:6900)
 

1 Answer, 1 is accepted

Sort by
0
John
Top achievements
Rank 1
answered on 23 Feb 2015, 11:56 PM
Found some typo's i.e. ({field: "Age:"}) has a ":" after Age in the field so please close.
Tags
Grid
Asked by
John
Top achievements
Rank 1
Answers by
John
Top achievements
Rank 1
Share this question
or