updateSeriesList (series, removed);
series. Sets series to be edited.
removed. Indicates if series are removed from collection.
The updateSeriesList method refreshes series list.
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:
//Variable that will store selected series var selSeries; //Repository interaction end handler. Used to set availability of the //Ungroup Series button depending on the selected series metabase.EndRequest.add(PP.Delegate(function(){ //Get selected workbook series selSeries = wbk.getActiveSheet().getSelectedSeries(); //Set button availability if (selSeries.length == 1 && PP.TS.isGroupSerie(selSeries[0])) { ungroupSeriesButt.setEnabled(True); } else { ungroupSeriesButt.setEnabled(False); } })); var ungroupSeriesButt = new PP.Ui.Button({ ParentNode: document.body, //DOM parent node Content: "Ungroup Series", //text Click: PP.Delegate(onClickUngroupSeries) }); function onClickUngroupSeries() { //Get and sort array of selected series var j; var Series = selSeries.sort(tsService._sorting.bind(wbk)); var realIndex = wbk.getRealIndex(undefined, Series[0]); var lastIndex = wbk.getRealIndex(undefined, Series[Series.length - 1]); //Get index of the last group series for (var i = 0; i < Series.length; i++) { lastIndex += wbk.getLoadedChildrenCount(Series[i]); } //Set properties of elements of series array for (j = 0; j < Series.length; j++) { Series[j].expanded = True; Series[j].atts = { its: { it: []} }; delete Series[j].calc; } //Get a body of server request for editing workbook series var body = tsService.getEditSeriesSettings(wbk, Series); //Enter information about selected series to the body of request body.SetWbkMd.tArg.metaGet.seriesFilter = { range: { start: realIndex, count: lastIndex - realIndex + 1 } }; //Set whether workbook is changed wbk.setIsChanged(True); //Send request to server tsService._send(body, onUngroupSeries); //UnGroupSeries method execution end event handler function onUngroupSeries(sender, args){ //Get JSON object from server response var res = JSON.parse(args.ResponseText); var groupSeries = Series; //Get workbook series var wbkSeries = res.SetWbkMdResult.meta.series.its.it; var series = []; var k = 1; //Refresh a list of series wbk.updateSeriesList(wbkSeries); //Get the number of group series var count = wbk.getLoadedChildrenCount(wbkSeries[0]); //Create an object that contains information about group series for (var j = 0; j < groupSeries.length; j++) { for (var i = 0; i < wbkSeries.length; i++) { if (wbkSeries[i].parent && wbkSeries[i].parent.k == groupSeries[j].k) { wbkSeries[i].atts = { its: { it: []} }; wbkSeries[i].index = Series[0].index + k; delete wbkSeries[i].calc; if (groupSeries[j].parent) wbkSeries[i].parent = groupSeries[j].parent; else { wbkSeries[i].parent = { k: -1, id: "" }; for (var kk = 0; kk < groupSeries.length; kk++) { if (wbkSeries[i].k == groupSeries[kk].k) { groupSeries[kk].parent = undefined; } } } series.push(wbkSeries[i]); k++; } } } //Get a body of server request for changing series var body = tsService.getEditSeriesSettings(wbk, series); //Get index of the first group series var start = wbk.getRealIndex(undefined, wbkSeries[0]); //Set parent series for each group series if (wbkSeries[0].parent) { var parentSerie = wbk.getSerie(wbkSeries[0].parent.k); start = wbk.getRealIndex(undefined, parentSerie); count = wbk.getLoadedChildrenCount(parentSerie) + 1; } //Enter information about gorup to the body of request body.SetWbkMd.tArg.metaGet.seriesFilter = { range: { start: start, count: count } }; //Set whether workbook is changed wbk.setIsChanged(True); //Send request to server tsService._send(body, refresh); //remove the series that was a group tsService.removeSeries(wbk, groupSeries, refresh); } } function refresh() { //Refresh the entire component for displaying workbook workbookBox.refreshAll(); }
After executing the example the button named Ungroup Series is placed on the HTML page. Select a grouped series and click this button. After this the grouped workbook series is ungrouped.
See also: