Skip to content

Commit f0eb36b

Browse files
setting filters feature & updating widget size fix
1 parent 95bcaeb commit f0eb36b

File tree

5 files changed

+115
-7
lines changed

5 files changed

+115
-7
lines changed

export/LightPivotTable.xml

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<Class name="DeepSee.LightPivotTable">
1313
<Super>%DeepSee.Component.Portlet.abstractPortlet</Super>
14-
<TimeChanged>63515,72475.367191</TimeChanged>
14+
<TimeChanged>63519,69139.707264</TimeChanged>
1515
<TimeCreated>63515,61322.546099</TimeCreated>
1616

1717
<Parameter name="INCLUDEFILES">
@@ -109,8 +109,6 @@
109109
}
110110
}
111111
112-
var _ = this;
113-
114112
setTimeout(function() { // onCreate fired when scripts are ready, but this.parent is missed.
115113
116114
// !ultra-bydlocode (get the widget object)
@@ -132,6 +130,8 @@
132130
break;
133131
}
134132
}
133+
//console.log(info);
134+
//console.log(_.getConnectedController());
135135
setup = {
136136
container: container,
137137
dataSource: {
@@ -141,12 +141,13 @@
141141
}
142142
post(source + "/DataSource", { DataSource: info["dataSource"] }, function (data) {
143143
144+
//console.log(data);
144145
if (data["rowAxisOptions"] && data["rowAxisOptions"]["drilldownSpec"]) {
145146
console.log(data["rowAxisOptions"]["drilldownSpec"]);
146147
setup.DrillDownExpression = data["rowAxisOptions"]["drilldownSpec"];
147148
}
148149
149-
new LightPivotTable(setup);
150+
_.LightPivotTable = new LightPivotTable(setup);
150151
151152
});
152153
}
@@ -161,10 +162,63 @@
161162
set ..renderFlag = ..renderFlag + 1
162163
163164
&html<
164-
<div data-source="#(..settings("dataSource"))#" class="lpt-container" style="position: absolute; left: 0; top: 0; width: 100%; height: 100%;">
165+
<div data-source="#(..settings("dataSource"))#" class="lpt-container" style="position: absolute; left: 0; bottom: 0; width: 100%; height: 100%;">
165166
166167
</div>
167168
>
169+
]]></Implementation>
170+
</Method>
171+
172+
<Method name="notifyViewHandler">
173+
<Description>
174+
Notification that the dataController associated with this dataView has raised an event.</Description>
175+
<FormalSpec>reason,data1,data2,data3</FormalSpec>
176+
<Language>javascript</Language>
177+
<ClientMethod>1</ClientMethod>
178+
<Implementation><![CDATA[
179+
if (!this.LightPivotTable) return;
180+
181+
var controller = this.getConnectedController();
182+
183+
if (reason === "dataChange") {
184+
185+
// updateFilters
186+
for (var i in controller.filters) {
187+
this.LightPivotTable.setFilter(controller.filters[i].spec);
188+
}
189+
190+
this.LightPivotTable.refresh();
191+
192+
}
193+
]]></Implementation>
194+
</Method>
195+
196+
<Method name="adjustContentSize">
197+
<Description>
198+
Notification from the containing widget that the page is loaded or the widget is resized.
199+
Subclass can implement this, if they wish.</Description>
200+
<FormalSpec>load,width,height</FormalSpec>
201+
<Language>javascript</Language>
202+
<ClientMethod>1</ClientMethod>
203+
<Implementation><![CDATA[
204+
if (!load && this.LightPivotTable) {
205+
this.LightPivotTable.updateSizes();
206+
}
207+
208+
// cheat-codes to make instrument panel visible
209+
210+
var outContainer = document.getElementById(this.id),
211+
inContainer;
212+
213+
if (outContainer) {
214+
for (var i in outContainer.childNodes) {
215+
if (outContainer.childNodes[i].className === "lpt-container") {
216+
inContainer = outContainer.childNodes[i];
217+
inContainer.style.height = outContainer.clientHeight + "px";
218+
break;
219+
}
220+
}
221+
}
168222
]]></Implementation>
169223
</Method>
170224
</Class>

source/js/DataSource.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ var DataSource = function (config) {
1515

1616
this.ACTION = config.action || "MDX";
1717

18+
this.FILTERS = [];
19+
1820
};
1921

2022
/**
@@ -78,16 +80,31 @@ DataSource.prototype._convert = function (data) {
7880

7981
};
8082

83+
/**
84+
* @param {string} spec - an MDX specification of the filter.
85+
*/
86+
DataSource.prototype.setFilter = function (spec) {
87+
88+
this.FILTERS.push(spec);
89+
90+
};
91+
8192
/**
8293
* @param {function} callback
8394
*/
8495
DataSource.prototype.getCurrentData = function (callback) {
8596

8697
var _ = this,
87-
__ = this._convert;
98+
__ = this._convert,
99+
mdx = this.BASIC_MDX,
100+
mdxParser = new MDXParser();
101+
102+
for (var i in this.FILTERS) {
103+
mdx = mdxParser.applyFilter(mdx, this.FILTERS[i]);
104+
}
88105

89106
this._post(this.SOURCE_URL + "/" + this.ACTION, {
90-
MDX: this.BASIC_MDX
107+
MDX: mdx
91108
}, function (data) {
92109
(data.Info || {}).action = _.ACTION;
93110
if (_.ACTION === "MDXDrillthrough") {

source/js/LightPivotTable.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,27 @@ LightPivotTable.prototype.refresh = function () {
4040

4141
};
4242

43+
/**
44+
* Performs resizing.
45+
*/
46+
LightPivotTable.prototype.updateSizes = function () {
47+
48+
this.pivotView.updateSizes();
49+
50+
};
51+
52+
/**
53+
* Ability to set filter. Manual refresh is required.
54+
* Example: spec = "[DateOfSale].[Actual].[YearSold].&[2009]"; *.refresh();
55+
*
56+
* @param {string} spec - an MDX specification of the filter.
57+
*/
58+
LightPivotTable.prototype.setFilter = function (spec) {
59+
60+
this.dataSource.setFilter(spec);
61+
62+
};
63+
4364
LightPivotTable.prototype.pushDataSource = function (config) {
4465

4566
var newDataSource;

source/js/MDXParser.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,14 @@ MDXParser.prototype.customDrillThrough = function (basicMDX, filters) {
115115

116116
return query;
117117

118+
};
119+
120+
/**
121+
* @param {string} basicMDX
122+
* @param {string} filterSpec
123+
*/
124+
MDXParser.prototype.applyFilter = function (basicMDX, filterSpec) {
125+
126+
return basicMDX + " %FILTER " + filterSpec;
127+
118128
};

source/js/PivotView.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ PivotView.prototype._sizesChanged = function () {
7373

7474
};
7575

76+
PivotView.prototype.updateSizes = function () {
77+
78+
this._sizesChanged();
79+
80+
};
81+
7682
PivotView.prototype._updateTablesPosition = function (seek) {
7783

7884
for (var i = 0; i < this.tablesStack.length; i++) {

0 commit comments

Comments
 (0)