Commit bb98ed69 authored by Alexander.Trofimov's avatar Alexander.Trofimov

fix getValue with CT_Index

fix update values with empty column fields
parent 698507be
......@@ -2708,18 +2708,22 @@ CT_pivotTableDefinition.prototype.getValues = function (records, index, value) {
var elem;
for (var i = 0; i < records.length; ++i) {
elem = records[i][index];
if (elem && 0 === elem.type && value === elem.v) {
if (elem && elem instanceof CT_Index && value === elem.v) {
res.push(records[i]);
}
}
return res;
};
CT_pivotTableDefinition.prototype.getValue = function (records, index) {
var cacheFields = this.asc_getCacheFields();
var res = 0;
var elem;
for (var i = 0; i < records.length; ++i) {
elem = records[i][index];
if (elem) {
if (elem instanceof CT_Index) {
elem = cacheFields[index].getSharedItem(elem.v);
}
if (elem instanceof CT_Number) {
res += elem.v;
}
}
......@@ -4090,7 +4094,6 @@ function CT_Index() {
//Attributes
this.v = null;
}
CT_Index.prototype.type = 0;
CT_Index.prototype.readAttributes = function(attr, uq) {
if (attr()) {
var vals = attr();
......
......@@ -4955,21 +4955,22 @@
var cacheValuesCol = [];
var cacheValuesRow = [];
// column
c1 = pivotRange.c1 + countR;
r1 = pivotRange.r1;
if (countC) {
c1 = pivotRange.c1 + countR;
r1 = pivotRange.r1;
cells = this.getRange4(r1, c1);
cells.setValue('Column Labels');
}
++r1;
++r1;
items = pivotTable.getColItems();
if (items && countC) {
for (i = 0; i < items.length; ++i) {
item = items[i];
r = item.getR();
cacheRecord = cacheRecords;
items = pivotTable.getColItems();
if (items) {
for (i = 0; i < items.length; ++i) {
item = items[i];
r = item.getR();
cacheRecord = cacheRecords;
if (countC) {
for (j = 0; j < item.x.length; ++j) {
if (AscCommonExcel.c_oAscItemType.Grand === item.t) {
field = null;
......@@ -4980,13 +4981,13 @@
indexField = colFields[r + j].asc_getIndex();
field = pivotFields[indexField];
cacheIndex = field.getItem(item.x[j].getV());
sharedItem = cacheFields[indexField].getSharedItem(cacheIndex.x);
// ToDo add other names by type
if (null !== item.t) {
oCellValue = new AscCommonExcel.CCellValue();
oCellValue.text = valuesWithFormat[r1 + r + j] + ' Total';
oCellValue.type = AscCommon.CellValueType.String;
} else {
sharedItem = cacheFields[indexField].getSharedItem(cacheIndex.x);
oCellValue = sharedItem.getCellValue();
}
......@@ -5004,13 +5005,14 @@
valuesWithFormat[r1 + r + j] = cells.getValueWithFormat();
}
}
if (countD) {
cacheValuesCol.push(cacheRecord);
}
}
if (countD) {
cacheValuesCol.push(cacheRecord);
}
}
}
// rows
if (countR) {
c1 = pivotRange.c1;
r1 = pivotRange.r1 + countC;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment