First place the json data
[{Date:'12-12-2015',ammu:20,appu:24,anu:27},{Date:'13-12-2016' ammu:23,anu:20}]
for this purpose i use the following code
function generateChartData() { var chartData = [], categories = {}; debugger; for ( var i = 0; i <Student.length; i++ ) { var newdate = Student[ i ].Date; var Name=Student[ i ].Name; var Mark=Student[ i ].Mark;
grid parameter is shown below:
$scope.gridOptions = { columnDefs: coldef(), enableFilter: true, rowData: [], rowSelection: 'multiple', rowDeselection: true, enableColResize: true, } }; $scope.gridOptions.columnDefs = $scope.customColumns; $scope.gridOptions.rowData =generateChartData(); $scope.gridOptions.rowData = generateChartData(); }
the column definition is dynamic, which is given below
function coldef() { for(var i=0;i<headers.length;i++) { debugger; $scope.customColumns.push( { headerName: headers[i], field:headers[i], headerClass: 'grid-halign-left', width:180, filter: 'set', }); } }
there is an array in this header. this array contains different student names
var headers=new Array(); headers[0]="DATE"; var Names= Student.map(function (item) { return item.Name}); Names= Names.filter(function (v, i) { return Names.indexOf(v) == i; }); for(var i=1;i<=Names.length;i++) { headers[i]=Names[i-1]; }