Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sdkjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
sdkjs
Commits
d471dbd8
Commit
d471dbd8
authored
Jul 25, 2017
by
Alexander.Trofimov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add update pageFields after add/remove
parent
6c909198
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
28 deletions
+67
-28
cell/api.js
cell/api.js
+12
-7
cell/model/PivotTables.js
cell/model/PivotTables.js
+28
-21
cell/model/Workbook.js
cell/model/Workbook.js
+27
-0
No files found.
cell/api.js
View file @
d471dbd8
...
...
@@ -3481,20 +3481,25 @@ var editor;
spreadsheet_api
.
prototype
.
_changePivotStyle
=
function
(
pivot
,
callback
)
{
var
t
=
this
;
var
changePivotStyle
=
function
(
res
)
{
var
ws
,
pivotRange
;
var
ws
,
wsModel
,
pivotRange
,
pos
,
i
;
if
(
res
)
{
wsModel
=
t
.
wbModel
.
getActiveWs
();
pivotRange
=
pivot
.
getRange
().
clone
();
for
(
i
=
0
;
i
<
pivot
.
pageFieldsPositions
.
length
;
++
i
)
{
pos
=
pivot
.
pageFieldsPositions
[
i
];
pivotRange
.
union3
(
pos
.
col
+
1
,
pos
.
row
);
}
History
.
Create_NewPoint
();
History
.
StartTransaction
();
callback
();
callback
(
wsModel
);
History
.
EndTransaction
();
pivotRange
=
pivot
.
getRange
().
clone
(
);
pivotRange
.
union2
(
pivot
.
getRange
()
);
// ToDo update ranges, not big range
var
pos
;
for
(
var
j
=
0
;
j
<
pivot
.
pageFieldsPositions
.
length
;
++
j
)
{
pos
=
pivot
.
pageFieldsPositions
[
j
];
for
(
i
=
0
;
i
<
pivot
.
pageFieldsPositions
.
length
;
++
i
)
{
pos
=
pivot
.
pageFieldsPositions
[
i
];
pivotRange
.
union3
(
pos
.
col
+
1
,
pos
.
row
);
}
t
.
wbModel
.
getActiveWs
()
.
updatePivotTablesStyle
(
pivotRange
);
wsModel
.
updatePivotTablesStyle
(
pivotRange
);
ws
=
t
.
wb
.
getWorksheet
();
ws
.
_onUpdateFormatTable
(
pivotRange
);
t
.
wb
.
_onWSSelectionChanged
();
...
...
cell/model/PivotTables.js
View file @
d471dbd8
...
...
@@ -2738,34 +2738,41 @@ CT_pivotTableDefinition.prototype.asc_setColGrandTotals = function(newVal) {
};
CT_pivotTableDefinition
.
prototype
.
asc_addPageField
=
function
(
api
,
index
)
{
var
t
=
this
;
api
.
_changePivotStyle
(
this
,
function
()
{
var
pivotField
=
t
.
asc_getPivotFields
()[
index
];
if
(
pivotField
)
{
if
(
c_oAscAxis
.
AxisPage
!==
pivotField
.
axis
)
{
t
.
removeField
(
index
);
}
else
{
// ToDo move to end ?
}
if
(
!
t
.
pageFields
)
{
t
.
pageFields
=
new
CT_PageFields
();
}
var
newField
=
new
CT_PageField
();
newField
.
fld
=
index
;
newField
.
hier
=
-
1
;
t
.
pageFields
.
add
(
newField
);
pivotField
.
axis
=
c_oAscAxis
.
AxisPage
;
t
.
location
.
addColPage
();
}
api
.
_changePivotStyle
(
this
,
function
(
ws
)
{
ws
.
clearPivotRable
(
t
);
t
.
addPageField
(
index
);
ws
.
updatePivotTable
(
t
);
});
};
CT_pivotTableDefinition
.
prototype
.
asc_removeField
=
function
(
api
,
index
)
{
var
t
=
this
;
api
.
_changePivotStyle
(
this
,
function
()
{
api
.
_changePivotStyle
(
this
,
function
(
ws
)
{
ws
.
clearPivotRable
(
t
);
t
.
removeField
(
index
);
ws
.
updatePivotTable
(
t
);
});
};
CT_pivotTableDefinition
.
prototype
.
addPageField
=
function
(
index
)
{
var
pivotField
=
this
.
asc_getPivotFields
()[
index
];
if
(
pivotField
)
{
if
(
c_oAscAxis
.
AxisPage
!==
pivotField
.
axis
)
{
this
.
removeField
(
index
);
}
else
{
// ToDo move to end ?
}
if
(
!
this
.
pageFields
)
{
this
.
pageFields
=
new
CT_PageFields
();
}
var
newField
=
new
CT_PageField
();
newField
.
fld
=
index
;
newField
.
hier
=
-
1
;
this
.
pageFields
.
add
(
newField
);
pivotField
.
axis
=
c_oAscAxis
.
AxisPage
;
this
.
location
.
addColPage
();
}
};
CT_pivotTableDefinition
.
prototype
.
removeField
=
function
(
index
)
{
var
pivotField
=
this
.
asc_getPivotFields
()[
index
];
switch
(
pivotField
.
axis
)
{
...
...
cell/model/Workbook.js
View file @
d471dbd8
...
...
@@ -4866,6 +4866,33 @@
this
.
pivotTables
[
i
].
init
();
}
};
Worksheet
.
prototype
.
clearPivotRable
=
function
(
pivotTable
)
{
var
pos
,
cells
;
for
(
var
i
=
0
;
i
<
pivotTable
.
pageFieldsPositions
.
length
;
++
i
)
{
pos
=
pivotTable
.
pageFieldsPositions
[
i
];
cells
=
this
.
getRange3
(
pos
.
row
,
pos
.
col
,
pos
.
row
,
pos
.
col
+
1
);
cells
.
clearTableStyle
();
cells
.
cleanAll
();
}
};
Worksheet
.
prototype
.
updatePivotTable
=
function
(
pivotTable
)
{
pivotTable
.
init
();
var
pos
,
cells
,
index
;
var
cacheFields
=
pivotTable
.
asc_getCacheFields
();
var
pivotFields
=
pivotTable
.
asc_getPivotFields
();
var
pageFields
=
pivotTable
.
asc_getPageFields
();
for
(
var
i
=
0
;
i
<
pivotTable
.
pageFieldsPositions
.
length
;
++
i
)
{
pos
=
pivotTable
.
pageFieldsPositions
[
i
];
cells
=
this
.
getRange3
(
pos
.
row
,
pos
.
col
,
pos
.
row
,
pos
.
col
);
index
=
pageFields
[
i
].
asc_getIndex
();
cells
.
setValue
(
pageFields
[
i
].
asc_getName
()
||
pivotFields
[
index
].
asc_getName
()
||
cacheFields
[
index
].
asc_getName
());
cells
=
this
.
getRange3
(
pos
.
row
,
pos
.
col
+
1
,
pos
.
row
,
pos
.
col
+
1
);
cells
.
setValue
(
'
(All)
'
);
}
};
Worksheet
.
prototype
.
updatePivotTablesStyle
=
function
(
range
)
{
var
pivotTable
,
pivotRange
,
styleInfo
,
style
,
wholeStyle
,
cells
,
j
,
pos
,
countC
,
countR
,
stripe1
,
stripe2
,
start
=
0
,
emptyStripe
=
new
Asc
.
CTableStyleElement
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment