$scope.loadPivot = function () {
$("#PivotGrids").remove();
var pivotGrid = ej.buildTag("div#PivotGrids", "", { height: 600, width: "60%", "float": "left", "overflow": "auto", "margin-top": "20px" })[0].outerHTML;
$(pivotGrid).appendTo(".controls");
$("#PivotSchemaDesigner").remove();
var schemaDesigner = ej.buildTag("div#PivotSchemaDesigner", "")[0].outerHTML;
$(schemaDesigner).appendTo(".PivotSchema");
console.log($scope.PivotData);
$scope.pivotRows = [],
$scope.pivotColumns = [],
$scope.pivotValues = [],
$scope.pivotSlicers = [],
angular.forEach($scope.PivotData, function (value) {
if (value.axis == "Rows") {
$scope.pivotRows.push({
fieldName: value.name,
fieldCaption: value.name
});
}
if (value.axis == "Columns") {
$scope.pivotColumns.push({
fieldName: value.name,
fieldCaption: value.name
});
}
if (value.axis == "values") {
$scope.pivotValues.push({
fieldName: value.name,
fieldCaption: value.name
});
}
if (value.axis == "Slicers") {
$scope.pivotSlicers.push({
fieldName: value.name,
fieldCaption: value.name
});
}
});
$("#PivotGrids").ejPivotGrid({
dataSource: {
data: $scope.PivotData,
rows: $scope.pivotRows,
columns: $scope.pivotColumns,
values: $scope.pivotValues
}
});
}