getPinSeriesSettings (wbk, allSeries);
wbk. Sets workbook, an instance of the Workbook class.
allSeries. Sets workbook series.
The getPinSeriesSettings method returns body of a request to pin workbook series.
To execute the example, the page must contain the WorkbookBox component named workbookBox (see Example of Creating the WorkbookBox Component), and the workbook must contain a calculated series. In the document opening event handler add the following code:
//Create an indicator to be used to determine whether there are blocked series in workbook
var someSerieIsPinnedFlag;
//Variable for storing selected series array
var selSeries;
//Button, clicking which blocks or unblocks the selected series
var pinSerieButton = new PP.Ui.Button({
ParentNode: document.body, //DOM parent node
Content: "Block Series", //Text
Click: PP.Delegate(onClickPinSerie)
});
//Block Series button click handler
function onClickPinSerie()
{
//Create an object containing a series for blocking or unblocking
var series = {};
series.its = {};
series.its.it = [];
//Create an object containing a series to be blocked
var pinnedSerie = {
id: "",
k: PP.Mb.UINT32MAXVALUE
};
if (selSeries && selSeries.length > 0)
{
var selSerie = undefined;
//Whether there are blocked series in the workbook, create an object passed to the
//pinSeries method as a parameter
if (!someSerieIsPinnedFlag)
{
selSerie = selSeries[0];
pinnedSerie.id = selSerie.id;
pinnedSerie.k = selSerie.k;
}
else
{
for (var i = 0; i < selSeries.length; i++)
{
series.its.it.push({
k: selSeries[i].k,
id: selSeries[i].id,
kind: selSeries[i].kind
});
}
}
}
series.pinned = pinnedSerie;
//Set blocking in the workbook
wbk.getActiveSheet().setPinned(pinnedSerie.k != PP.Mb.UINT32MAXVALUE ? pinnedSerie : undefined);
//Get body of request for blocking workbook series
var body = tsService.getPinSeriesSettings(wbk, series);
//Set whether workbook is changed
wbk.setIsChanged(True);
//Send request to server for blocking workbook series
tsService._send(body, PP.Delegate(onResponse));
}
//pinSeries method execution end event handler
function onResponse()
{
//Refresh entire component to display workbook
workbookBox.refreshAll();
}
//Repository interaction end handler. Used to set availability of the
//"Block Series" button depending on whether it is available to block the selected series and set whether
//there are blocked series in the workbook
metabase.EndRequest.add(PP.Delegate(function(){
selSeries = wbk.getActiveSheet().getSelectedSeries();
if (selSeries.length == 1 && selSeries[0].calc && selSeries[0].calc.formula)
{
pinSerieButton.setEnabled(True);
}
else
{
pinSerieButton.setEnabled(False);
}
someSerieIsPinnedFlag = (wbk.getActiveSheet().getPinned() ? true : false);
}));
After executing the example the Block Series button is placed in the HTML page. On clicking this button the selected calculated series is locked.
See also: