TSService.pinSeries

Syntax

pinSeries (wbk, series, callback);

Parameters

wbk. Sets workbook value.

series. Sets series.

callback. Sets handler for operation execution end.

Description

The pinSeries method pins series.

Example

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 used to store array of selected series
	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 event
	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 for blocking
		var pinnedSerie = {
			id: "",
			k: PP.Mb.UINT32MAXVALUE
			};	
										
		if (selSeries && selSeries.length > 0)
		{	
			var selSerie = undefined;
			//Depending on whether there are blocked series in 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 workbook
			wbk.getActiveSheet().setPinned(pinnedSerie.k != PP.Mb.UINT32MAXVALUE ? pinnedSerie : undefined);
			//Block the selected series
			tsService.pinSeries(wbk.getActiveSheet(), series, PP.Delegate(onResponse))					
		}
				
		//pinSeries method execution end event handler
		function onResponse()
		{
			//Refresh entore component for displaying 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 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. Select a calculated series and click the Block Series button. After that the selected series is blocked.

See also:

TSService