Hello Sastha,
i have a function to build pivot with data from database:
$scope.loadPivot = function () {
$("#PivotGrid").remove();
var pivotGrid = ej.buildTag("div#PivotGrid", "", {
width: "100%",
"overflow": "auto",
"float": "left",
"margin-top": "20px"
})[0].outerHTML;
$(pivotGrid).appendTo(".controls");
$("#PivotSchemaDesigner").remove();
var schemaDesigner = ej.buildTag("div#PivotSchemaDesigner", "")[0].outerHTML;
$(schemaDesigner).appendTo(".PivotSchema");
$scope.pivotRows = [],
$scope.pivotColumns = [],
$scope.pivotValues = [],
$scope.pivotSlicers = [],
angular.forEach($scope.PivotData, function (value) {
if (value.axis == "Rows") {
$scope.pivotRows.push({
fieldName: value.fieldName,
fieldCaption: value.fieldName
});
}
if (value.axis == "Columns") {
$scope.pivotColumns.push({
fieldName: value.fieldName,
fieldCaption: value.fieldName
});
}
if (value.axis == "values") {
$scope.pivotValues.push({
fieldName: value.fieldName,
fieldCaption: value.fieldName
});
}
if (value.axis == "Slicers") {
$scope.pivotSlicers.push({
fieldName: value.fieldName,
fieldCaption: value.fieldName
});
}
});
$("#PivotGrid").ejPivotGrid({
dataSource: {
data: $scope.PivotData,
rows: $scope.pivotRows,
columns: $scope.pivotColumns,
values: $scope.pivotValues
}
});
}
in the Console, the data is valid.
the error occurs here:
$.grep(tableKeysCalcValues, function (item) {
if (item.uniqueName == rowKeysCalcValues[rCnt].uniqueName)
for (ky = 0 ; ky < item.value.keys.length; ky++)
calValue.push(item.value.keys[ky]);
return;
});
JQuery:
grep: function( elems, callback, invert ) {
var callbackInverse,
matches = [],
i = 0,
length = elems.length,
callbackExpect = !invert;
// Go through the array, only saving the items
// that pass the validator function
for ( ; i < length; i++ ) {
callbackInverse = !callback( elems[ i ], i );
if ( callbackInverse !== callbackExpect ) {
matches.push( elems[ i ] );
}
}
return matches;
},
at this point, elems:
- Object
- keys:Array[1]
- 0:"(blank)"
- length:1
- __proto__:Array[0]
- uniqueName:"(blank)"
- value:null
Hope that helps