getSelectedOrPinnedSeries();
The getSelectedOrPinnedSeries method returns selected series or the pinned series if there is any.
To execute the example, the page must contain the WorkbookBox component named workbookBox (see Example of Creating the WorkbookBox Component), and also add the following code in the handler, that processes document opening event:
//Get all series' series var _Series = wbk.getActiveSheet().getSeries(); //Add a handler to the metabase connection end event that //sets availability of the Collapse Expanded button metabase.EndRequest.add(function (){ collapseSeriesButton.setEnabled(False); _Series = wbk.getActiveSheet().getSeries(); var i; //Get all expanded group and calculated series and collapse them for(i = 0; i < _Series.length; i++) { if(_Series[i].expanded && (_Series[i].expanded === True)) { collapseSeriesButton.setEnabled(True); break; } } }); //Series collapse operation end handler var callback = PP.Delegate(function(){ //Refresh the entire component to display workbook workbookBox.refreshAll(); }); var collapseSeriesButton = new PP.Ui.Button({ ParentNode: document.body, //DOM parent node Content: "Collapse Expanded", //Text Click: PP.Delegate(onClickCollapseSeries) }); function onClickCollapseSeries() { var i; //get all expanded group and calculated series and collapse them for(i = 0; i < _Series.length; i++) { if(_Series[i].expanded && (_Series[i].expanded === True)) { collapeSerie(_Series[i]); } } } function collapeSerie(Series) { var args = undefined; //Create an object that contains information about the expanded series _series = { k: Series.k, kind: Series.kind, index: Series.index, childrenCount: Series.childrenCount }; _series.expanded = False; _series.atts = { its: { it: []} }; series = [_series]; //Create a body of server request for collapsing of series var body = { SetWbkMd: { tWbk: wbk.getOdId(), tArg: { pattern: { series: 'Change' }, metaGet: tsService._getWbkSeriesPattern(), meta: { series: { its: { it: series } } } } } }; //It is required to get tabsheet structure to set correct width and height of added series body.SetWbkMd.tArg.metaGet.getTabSheet = { pattern: { DHTML: True, structure: True } }; //Add information about tabsheet structure to the body of server request if (series.length == 1 || wbk.getPinned()) { var res = { it: [] }; if (wbk.getPinned()) res.it.push({ k: wbk.getSelectedOrPinnedSeries()[0].k }); else { var ser = series[0]; if (ser) res.it.push({ k: ser.k }); } if (res) { body.SetWbkMd.tArg.metaGet.results = { correlation: True, coefficients: True, tabSheet: True, series: res }; } } tsService._addViewSettings(wbk, body.SetWbkMd); //Set whether workbook is changed wbk.setIsChanged(True); //Sort array of series series = series.sort(tsService._sorting.bind(wbk)); //Get indexes of the first and the last group series var firstIndex = wbk.getRealIndex(undefined, series[0]); var lastIndex = wbk.getRealIndex(undefined, series[series.length - 1]); //Remove child series of the expanded workbook series wbk.removeSeries(wbk.getRealIndex(undefined, series[0]) + 1, series[0].childrenCount); //Add information about child series of the group series body.SetWbkMd.tArg.metaGet.seriesFilter = { range: { start: firstIndex, count: (lastIndex - firstIndex + 1) } }; //Add procedures to the mailing list of server response delivery event callback = tsService._visitCallback(callback, new PP.Delegate(tsService._editSerieCompleted, tsService, { Workbook: wbk, Expanding: False })); callback = tsService._visitCallback(callback, new PP.Delegate(tsService._OnOpened, tsService, { Workbook: wbk, MetaData: args })); //Send request to server tsService._send(body, callback); }
After executing the example the button named Collapse Expanded is placed in the HTML page. To execute the example, the workbook must contain an expanded series. Select such a series and click the Collapse Expanded button. On clicking this button the selected series is collapsed.
See also: