TSService.removeColumns

Syntax

removeColumns (wbk, columns, callback);

Parameters

wbk. Sets workbook value.

columns. Sets columns in a table.

callback. Sets handler for operation execution end.

Description

The removeColumns method removes columns of workbook attributes.

Example

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:

	//Add the handler to the metavase connection end event that 
	//sets availability of the Remove Last Column button depending on the number of attribute columns
	metabase.EndRequest.add(PP.Delegate(function(){									
		if(wbk.getActiveSheet().getWbkMetadata().columns.its.it.length > 1)
		{
			removeColumnButt.setEnabled(True);
		}
		else
		{
			removeColumnButt.setEnabled(False);
		}
	}));
												
	var removeColumnButt = new PP.Ui.Button({
		ParentNode: document.body, //DOM parent node
		Content: 'Remove Last Attribute Column' , //Text
		Click: PP.Delegate(onClickRemoveColumn)
	});
	function onClickRemoveColumn()
	{	
		//Get array of workbook attribute columns
		var columns = wbk.getActiveSheet().getWbkMetadata().columns.its.it;
		//Create an object containing information about removed last attribute column					
		var column = [{
			k: columns[columns.length-1].k,
			type: columns[columns.length-1].type,
			vis: columns[columns.length-1].vis,
			readOnly: columns[columns.length-1].readOnly
		}];
		//Remove last attribute column
		tsService.removeColumns(wbk.getActiveSheet(), column, PP.Delegate(onResponse));
		function onResponse(sender, args)
		{
			//Refresh the workbookBox component
			workbookBox.refreshAll();
		}					
	}

After executing the example the Delete the Last Column button is placed in the HTML page. To make the button active, the workbook must contain two or more attribute columns . To add an attribute column to workbook, select one or more nodes in the Attributes tree in the Data workbook properties panel on the Format tab.

On clicking the button the last attribute column in the workbook is removed.

Before clicking the button:

After clicking the button:

See also:

TSService