I use Angular App and DataTables. In one of my components I have a DataTable which pulls data from an external API using the "ajax" property of the options object.
export class ChartsDetailsComponent implements OnInit {
ngOnInit(): void {
var opts: any = {
ajax :{
url: this.appConfigService.analyseConfig.chartsApiUrl + "/api/Charts/GetChartDetails?type=" + this.chartType,
dataSrc: "ChartData." + this.chartType
},
columns:[
{title:"Name"},
{title:"Status"},
]
};
var table = $('#details').DataTable(opts);
}
}
The returned data has the following structure:
{
"ChartData":{
"FQCInLocalChart":[
["EM/AC.08.2.01","Remote"],
["EM/AC.08.2.03","Remote"]
]
}
}
The FQCInLocalChart is dynamic. It is not static property. That's why in the dataSrc property I put "ChartData." + this.chartType, where this.chartType is a private property of the Angular component.
The data source contains only the columns that has to be displayed, but I would like to have a row number before the columns that are filled with the returned from the API data. Is there a way to achieve this behavior?
Thanks in advance Julian

columnsproperty of the options to be an array like[{title:"First Column"},{title;"Second Column"}], and when I add for example an empty column (or another object in the array), the first column is always containing the first column from the data that is coming from the ajax response. Is there a way to shift (somehow) and tell to fill the datasource from the second column?