Delete Range

From Documentation
Revision as of 12:38, 19 November 2010 by Samchuang (talk | contribs) (Created page with '{{ZKSpreadsheetEssentialsPageHeader}} __TOC__ ZK Spreadsheet can use Range.delete to delete row or column. ==Scenario== User right click to open a menu and delete row or colum…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


ZK Spreadsheet can use Range.delete to delete row or column.

Scenario

User right click to open a menu and delete row or column.

ZUML Example

<zk>
<div height="100%" width="100%" apply="demo.DeleteRangeComposer">
	<div height="3px"></div>
	<menupopup id="cellMenupopup">
		<menuitem id="shiftCellLeft" label="Shift cells left"></menuitem>
		<menuitem id="shiftCellUp" label="Shift cells up"/>
		<menuitem id="deleteEntireRow" label="Entire row" />
		<menuitem id="deleteEntireColumn" label="Entire column" />
	</menupopup>
	<spreadsheet id="spreadsheet" src="/demo_sample.xls"	
			maxrows="200" 
			maxcolumns="40"
			width="100%"
			height="450px"></spreadsheet>
</div>
</zk>

Open menu

We can use onCellRightClick to get the current mouse position and open popup.

int rowIndex;
int colIndex;
Sheet currentSheet;
Spreadsheet spreadsheet;
Menupopup cellMenupopup;
public void onCellRightClick$spreadsheet(CellMouseEvent event) {
	rowIndex = event.getRow();
	colIndex = event.getColumn();
	currentSheet = event.getSheet();
	cellMenupopup.open(event.getPageX(), event.getPageY());
}

Shift cells left

public void onClick$shiftCellLeft() {
	Range rng = Ranges.range(currentSheet, rowIndex, colIndex);
	rng.delete(Range.SHIFT_LEFT);
}

Shift cells up

public void onClick$shiftCellUp() {
	final Range rng = Ranges.range(currentSheet, rowIndex, colIndex);
	rng.delete(Range.SHIFT_UP);
}

Version History

Last Update : 2010/11/19


Version Date Content
     


All source code listed in this book is at Github.


Last Update : 2010/11/19

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.