@@ -196,12 +196,12 @@ If LPT has been created before, method fires given callback immidiately.</Descri
196196 defaultFilters = [],
197197 exportToExcel = !!parseInt(container.getAttribute("export-csv"));
198198
199- // !ultra-bydlocode (get the widget object)
200- while (widget["parent "]) {
199+ // Following "parent" until we find widget object
200+ while (! widget["widgetKey "]) {
201201 widget = widget["parent"];
202202 }
203- // !ultra-bydlocode (possible you will have better suggestions to get widget key)
204- widgetKey = parseInt(_.parent.parent.onwindowgrab.match(/[0-9]+/)[0]) ;
203+
204+ widgetKey = widget["widgetKey"] ;
205205
206206 if (exportToExcel) {
207207 var widgetHead = document.getElementById(basicContainer.getAttribute("id").replace(/\/.*/, "/header"));
@@ -247,7 +247,7 @@ If LPT has been created before, method fires given callback immidiately.</Descri
247247 (source = location.origin + "/" + container.getAttribute("data-source"))
248248 + "/Widgets?Namespace=" + container.getAttribute("namespace"),
249249 {
250- Dashboard: widget ["dashboardName"]
250+ Dashboard: zenPage ["dashboardName"]
251251 },
252252 function (data) {
253253 if (data.error) {
@@ -260,16 +260,6 @@ If LPT has been created before, method fires given callback immidiately.</Descri
260260 }
261261 }
262262 //console.log(info);
263- if (info.controls instanceof Array) {
264- for (i in info.controls) {
265- if ((info.controls[i].action === "applyFilter" || info.controls[i].action === "setFilter") && info.controls[i].value) {
266- if ((filterValue = info.controls[i].value).charAt(0) === "%" && filterValue.indexOf(" ") > 1) {
267- filterValue = filterValue.split(" ")[1] + "." + filterValue.split(" ")[0]
268- }
269- defaultFilters.push(info.controls[i].targetProperty + "." + filterValue);
270- }
271- }
272- }
273263 setup = {
274264 container: container,
275265 dataSource: {
@@ -286,6 +276,21 @@ If LPT has been created before, method fires given callback immidiately.</Descri
286276 }
287277 }
288278 }
279+ // Getting filters from controller, if it has filters added from URL or default...
280+ // such filters are marked as "transient"
281+ if (controller.filters.length) {
282+ for (i in controller.filters) {
283+ if (controller.filters[i].enabled && controller.filters[i].transient)
284+ defaultFilters.push(controller.filters[i].spec);
285+ }
286+ }
287+ // ... if not, we'll get filters from widget's controls
288+ // Only if the controller didn't have transient filters - (!defaultFilters.length)
289+ if (!defaultFilters.length && widget.filterState instanceof Object) {
290+ for (i in widget.filterState)
291+ if (widget.filterState[i]) defaultFilters.push(widget.constructMDXClause(i,widget.filterState[i]));
292+ }
293+
289294 if (controller.contextFilterSpec) {
290295 defaultFilters.push(controller.contextFilterSpec);
291296 }
0 commit comments