Class
zebkit.ui.grid.Grid
mixed with <zebkit.ui.grid.Metrics> <zebkit.ui.HostDecorativeViews> extends <zebkit.ui.Panel> |
<zebkit.ui.grid> |
Grid UI component class. The grid component visualizes "zebkit.data.Matrix" data model. Grid cell visualization can be customized by defining and setting an own view provider. Grid component supports cell editing. Every existent UI component can be configured as a cell editor by defining an own editor provider.
// create a grid that contains three rows and tree columns
var grid = new zebkit.ui.grid.Grid([
[ "Cell 1.1", "Cell 1.2", "Cell 1.3"],
[ "Cell 2.1", "Cell 2.2", "Cell 2.3"],
[ "Cell 3.1", "Cell 3.2", "Cell 3.3"]
]);
// add the top caption
grid.add("top", new zebkit.ui.grid.GridCaption([
"Caption title 1", "Caption title 2", "Caption title 3"
]));
// set rows size
grid.setRowsHeight(45);
Grid can have top and left captions.
zebkit.ui.grid.Grid
([model], [rows], [columns]
)
Parameters:
-
[model]
<zebkit.data.Matrix | Array>a matrix model to be visualized with the grid component. It can be an instance of zebkit.data.Matrix class or an array that contains embedded arrays. Every embedded array is a grid row.
-
[rows]
<Integer>a number of rows
-
[columns]
<Integer>a number of columns
private
<zebkit.draw.View>
$getPosMarker ( )
Get position marker view taking in account focus state.
Returns:
<zebkit.draw.View>
a position marker view |
private
<Integer>
$initialCellX ( )
Initial (not scrolled) x coordinate of first cell
Returns:
<Integer>
initial x coordinate |
private
<Integer>
$initialCellY ( )
Initial (not scrolled) y coordinate of first cell
Returns:
<Integer>
initial y coordinate |
public
void
catchScrolled (psx, psy )
Scroll action handler Parameters:
|
public
<Object>
cellByLocation (x, y )
Detect a cell by the given location Parameters:
Returns:
<Object>
an object that contains detected grid cell row as "row" field and a grid column as "col" field. null is returned if no cell can be detected. |
public
chainable
clearSelect ( )
Clear grid row or rows selection |
public
<zebkit.draw.View>
getCellView (row, col )
Return a view that is used to render the given grid cell. Parameters:
Returns:
<zebkit.draw.View>
a cell view |
public
<Integer>
getColPSWidth (col )
Get a preferred width the given column wants to have Parameters:
Returns:
<Integer>
a preferred width of the given column |
@Override
zebkit.ui.grid.Metrics
public <Integer> getColWidth (col )
Get the given grid column width Parameters:
Returns:
<Integer>
a width of the given column |
public
<Integer>
getColX (col )
Get the given column top-left corner x coordinate Parameters:
Returns:
<Integer>
a top-left corner x coordinate of the given column |
public
<Integer>
getColX (row )
Get the given row top-left corner y coordinate Parameters:
Returns:
<Integer>
a top-left corner y coordinate of the given column |
public
<Integer>
getGridColumns ( )
Get number of columns in the given grid
Returns:
<Integer>
a number of columns |
@Override
zebkit.ui.grid.Metrics
public <Integer> getGridRows ( )
Get number of rows in the given grid
Returns:
<Integer>
a number of rows |
protected
<Integer>
getLeftCaptionWidth ( )
Get left grid caption width. Return zero if no left caption element has been defined
Returns:
<Integer>
a left caption width |
@Override
zebkit.ui.grid.Metrics
public <Integer> getRowHeight (row )
Get the given grid row height Parameters:
Returns:
<Integer>
a height of the given row |
public
<Integer>
getRowPSHeight (col )
Get a preferred height the given row wants to have Parameters:
Returns:
<Integer>
a preferred height of the given row |
protected
<Integer>
getTopCaptionHeight ( )
Get top grid caption height. Return zero if no top caption element has been defined
Returns:
<Integer>
a top caption height |
public
void
keyPressed (e )
Implement key pressed handler. Parameters:
|
public
void
keyReleased (e )
Implement key released handler. Parameters:
|
public
void
keyTyped (e )
Implement key type handler. Parameters:
|
public
chainable
makeVisible (row, col )
Make the given cell visible. Parameters:
|
protected
<Integer>
pageSize (d )
Calculate number of rows to be scrolled up or down to scroll one page Parameters:
Returns:
<Integer>
a page size in rows to be scrolled up or down |
protected
void
paintCellSelection (g, row, col, x, y )
Paint a selection for the given grid cell Parameters:
|
protected
void
paintData (g )
Paint grid data Parameters:
|
protected
void
paintNet (g )
Paint vertical and horizontal grid component lines Parameters:
|
protected
void
paintPosMarker (g )
Paint position marker. Parameters:
|
public
void
posChanged (target, prevOffset, prevLine, prevCol )
Position changed event handler. Parameters:
|
public
chainable
repaintCells (r1, c1, [r2], [c2] )
Repaint cells. Parameters:
|
public
chainable
repaintCols (c1, c2 )
Repaint range of grid columns Parameters:
|
public
chainable
repaintRows (r1, r2 )
Repaint range of grid rows Parameters:
|
public
chainable
select (row, [col], [b] )
Mark as selected or unselected the given grid cell Parameters:
|
public
chainable
setCellPadding (p )
Set the given top, left, right, bottom cell paddings Parameters:
|
public
chainable
setCellPaddings (t, l, b, r )
Set the given top, left, right, bottom cell paddings Parameters:
|
public
chainable
setColsWidth ([col], [len], w )
Set the given width for all or the specified range of columns Parameters:
|
@Override
zebkit.ui.grid.Metrics
public chainable setColWidth (column, w )
Set the given width for the specified grid column. The method has no effect if the grid component is forced to use preferred size metric. Parameters:
|
public
chainable
setDefCellXAlignment (ax )
Set the grid cell content default horizontal alignment. Parameters:
|
public
chainable
setDefCellYAlignment (ay )
Set the grid cell default vertical alignment. Parameters:
|
public
chainable
setDrawCaptionLines (b )
Control rendering of grid lines on grid caption. Parameters:
|
protected
void
setEditedData (row, col, an )
Apply the given edited data to grid matrix model Parameters:
|
public
chainable
setEditorProvider (p )
Set the given editor provider. Editor provider is a way to customize cell editing. Parameters:
|
public
chainable
setLeftCaption (title )
Set the grid left caption titles Parameters:
|
public
chainable
setLineColor (c )
Set the given color to render the grid vertical and horizontal lines Parameters:
|
public
chainable
setLineSize (s )
Set the given grid lines size Parameters:
|
public
chainable
setModel (d )
Set the given matrix model to be visualized and controlled with the grid component Parameters:
|
public
chainable
setNavigationMode (mode )
Set navigation mode. It is possible to use "row" or "cell" or "col" navigation mode. In first case navigation happens over row, in the second case navigation happens over cell. Parameters:
|
public
chainable
setPosition (p )
Set the position controller. Parameters:
|
@Override
zebkit.ui.grid.Metrics
public chainable setRowHeight (row, h )
Set the given height for the specified grid row. The method has no effect if the grid component is forced to use preferred size metric. Parameters:
|
public
chainable
setRowsHeight ([row], [len], h )
Set the given height for all or the specified range of rows Parameters:
|
public
chainable
setSelectMode (mode )
Set the given grid cell select mode. Parameters:
|
public
chainable
setTopCaption (title )
Set the grid top caption titles Parameters:
|
public
chainable
setUsePsMetric (b )
Force to size grid columns and rows according to its preferred size Parameters:
|
public
chainable
setViewProvider (p )
Set the given cell view provider. Provider is a special class that says how grid cells content has to be rendered, aligned, colored Parameters:
|
@Override
zebkit.ui.HostDecorativeViews
public void setViews (a )
Set number of views to render different grid component elements Parameters:
|
public
<Boolean>
startEditing (row, col )
Start editing the given grid cell. Editing is initiated only if an editor provider has been set and the editor provider defines not-null UI component as an editor for the given cell. Parameters:
Returns:
<Boolean>
true if a cell editor has been initiated, otherwise returns false. |
protected
void
stopEditing (applyData )
Stop editing a grid cell. Parameters:
|












public
![]() cellInsetsBottom
Grid cell bottom padding |
public
![]() cellInsetsLeft
Grid cell left padding |
public
![]() cellInsetsRight
Grid cell right padding |
public
![]() cellInsetsTop
Grid cell top padding |
public
![]() editingCol
Currently editing column. -1 if no column is editing |
public
![]() editingRow
Currently editing row. -1 if no row is editing |
public
![]() isUsePsMetric
/* Overwritten from isUsePsMetric */
Indicate if size of grid cells have to be calculated automatically basing on its preferred heights and widths |
public
![]() leftCaption
Reference to left caption component |
public
<Integer>
lineSize
/* Overwritten from lineSize */
Grid line size |
public
![]() selectMode
Grid cell select mode |
public
![]() topCaption
Reference to top caption component |
selected
Fire when a grid row selection state has been changed
Parameters:
|