I have the following json array of object.
$scope.headerColumns = [{
"label": "ABC",
"order": 1,
"type": "dropbox"
}, {
"label": "XYZ",
"order": 2,
"group": "GroupB",
"type": "textbox"
}]
Now I need to add few more properties to these json objects to contain the following additional information.
{
headerName: "Businesses",
field: "business",
cellStyle: {
'text-align': 'center'
},
headerCellRenderer: function(params) {
params.$scope.businessItems = _self.businessItems;
return '<span>Businesses</span></br><dropdown-select values=\'businessItems\'></dropdown-select> '
}
}
So I am iterating my json array and adding the new properties as shown below:
angular.forEach($scope.headerColumns, function(eachHeaderColumn) {
eachHeaderColumn["headerName"] = eachHeaderColumn.label;
eachHeaderColumn["field"] = "busDesc";
eachHeaderColumn["id"] = "busNum";
$scope.formattedheaderColumns.push(eachHeaderColumn);
});
Till here it is fine, now I stuck up, not knowing how to add cellStyle and headerCellRenderer for each json object in the above angular.forEach loop. Can any one help me please in this?
After formatting my final Json should as shown below :
$scope.formattedHeaderColumns = [{
label: "ABC",
order: 1,
type: "dropbox",
headerName: "ABC", //mapped to label
field: "busDesc", //if order ==1, then field would be "busDesc"
cellStyle: {
'text-align': 'center'
},
headerCellRenderer: function(params) { //if type == dropbox, we have function to return the dropdown
params.$scope.businessItems = _self.businessItems;
return '<span>Businesses</span></br><dropdown-select values=\'businessItems\'></dropdown-select> '
}
}, {
label: "XYZ",
order: 2,
group: "GroupB",
headerGroup: 'GroupB', //header group should be mapped to group, if group is present
type: "textbox",
headerName: "XYZ", //mapped to label
field: "busEntry", //if order ==2, then field would be "busEntry"
cellStyle: {
'text-align': 'center'
},
headerCellRenderer: function(params) { //if type == textbox, we have function to return the input box with type = text
return '<span>XYZ</span></br><input class="exp-param-header-input" type="text" value=' + params.value + '> </br> <span> <span class="glyphicon glyphicon-download"></span> Apply To All</span>'
}
}]