com.extjs.gxt.ui.client.widget.table
Class Table

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.extjs.gxt.ui.client.widget.Component
              extended by com.extjs.gxt.ui.client.widget.BoxComponent
                  extended by com.extjs.gxt.ui.client.widget.Container<TableItem>
                      extended by com.extjs.gxt.ui.client.widget.table.Table
All Implemented Interfaces:
Observable, Selectable<TableItem>, BaseTable, com.google.gwt.user.client.EventListener

public class Table
extends Container<TableItem>
implements BaseTable, Selectable<TableItem>

The table is used to display two-dimensional table of cells.

Events:
BeforeAdd : TableEvent(table, item)
Fires before a item is added or inserted. Listeners can set the doit field to false to cancel the action.
BeforeRemove : TableEvent(table, item)
Fires before a item is removed. Listeners can set the doit field to false to cancel the action.
Add : TableEvent(table, item)
Fires after a item has been added or inserted.
Remove : TableEvent(table this, item)
Fires after a item has been removed.
SelectionChange : TableEvent(table this)
Fired after the selection has changed
ContextMenu : TableEvent(table)
Fires before the tables context menu is shown. Listeners can set the doit field to false to cancel the action.
CellClick : TableEvent(table, rowIndex, cellIndex, event)
Fires after a cell is clicked.
CellDoubleClick : TableEvent(table, rowIndex, cellIndex, event)
Fires after a cell is double clicked.
ColumnClick : TableEvent(table, columnIndex)
Fires after a column is clicked.
RowClick : TableEvent(table, rowIndex, cell index, event)
Fires after a row is clicked.
RowDoubleClick : TableEvent(table, rowIndex, cellIndex, event)
Fires after a row is double clicked.
SortChange : TableEvent(table, colIndex, sortDir)
Fires before the table is sorted. Listeners can set the doit field to false to cancel the action.
SelectionChange : TableEvent(table, selected)
Fires after a item has been removed.
KeyPress : TableEvent(table)
Fires before the table is sorted. Listeners can set the doit field to false to cancel the action.
HeaderContextMenu : TableEvent(table, colIndex, menu)
Fires right before the header's context menu is displayed.
CSS:
.my-tbl-col-[column id] { each column }
.my-tbl-td-[column index] { cell td }
.my-tbl-td-inner-[column index] { cell inner element }
.my-tbl-td-cell-[column index] { cell text element }

See Also:
TableColumn, TableColumnModel

Nested Class Summary
 
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled
 
Field Summary
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
Table()
          Creates a new single select table.
Table(TableColumnModel cm)
          Creates a new table.
 
Method Summary
 boolean add(TableItem item)
          Adds a item to the container.
 void addTableListener(TableListener listener)
          Adds a table listener.
 boolean getBulkRender()
          Returns true if bulk rendering is enabled.
 TableColumn getColumn(int index)
          Returns the column at the specified index.
 TableColumn getColumn(java.lang.String id)
          Returns the column with the given id.
 boolean getColumnContextMenu()
          Returns the column context menu enabed state.
 int getColumnCount()
          Returns the number of columns contained in the table.
 TableColumnModel getColumnModel()
          Returns the table's column model.
 Menu getContextMenu()
          Returns the component's context menu.
 boolean getHighlight()
          Returns true if highlights are enabled.
 boolean getHorizontalScroll()
          Returns true if horizontal scrolling is enabled
 TableItem getSelectedItem()
          Returns the selected item.
 java.util.List<TableItem> getSelectedItems()
          Returns the selected items.
 Style.SelectionMode getSelectionMode()
           
 TableSelectionModel getSelectionModel()
          Returns the table's selection model.
 TableHeader getTableHeader()
          Returns the table's header.
 boolean getVerticalLines()
          Returns true if vertical lines are enabled.
 TableView getView()
          Returns the table's view.
 boolean insert(TableItem item, int index)
          Addss a item into the container.
 void onBrowserEvent(com.google.gwt.user.client.Event event)
          Components delegate event handling to Component.onComponentEvent(ComponentEvent).
 void onComponentEvent(ComponentEvent ce)
          Any events a component receives will be forwarded to this method.
 void onSelectChange(TableItem item, boolean select)
          Called when the visual state of a item is changed.
 void recalculate()
          Called when the component is in a LayoutContainer and the container's layout executes.
 boolean remove(TableItem item)
          Removes the item from the container.
 void removeTableLisetener(TableListener listener)
          Remvoves a table listener.
 void scrollIntoView(TableItem item)
          Scrolls the item into view.
 void setBulkRender(boolean bulkRender)
          True to bulk render the table when first rendered (defaults to true).
 void setColumnContextMenu(boolean columnContextMenu)
          Sets whether the table header context menu is displayed (defaults to true).
 void setColumnModel(TableColumnModel cm)
          Sets the table's column model.
 void setContextMenu(Menu menu)
          Sets the component's context menu.
 void setHighlight(boolean highlight)
          True to highlight the current row (defaults to true).
 void setHorizontalScroll(boolean horizontalScroll)
          True to display a horizonatal scroll bar when needed (defaults to true).
 void setSelectedItem(TableItem item)
          Selects the item.
 void setSelectedItems(java.util.List<TableItem> items)
          Selects the items.
 void setSelectionMode(Style.SelectionMode mode)
          Sets the table's selection mode.
 void setSelectionModel(TableSelectionModel sm)
          Sets the table's selection model.
 void setTableHeader(TableHeader header)
          Sets the table's header.
 void setVerticalLines(boolean verticalLines)
          True to display vertical borders on the table data (defaults to false).
 void setView(TableView view)
          Sets the table's view.
 void sort(int index, Style.SortDir sortDir)
          Sorts the table using the specified column index.
 
Methods inherited from class com.extjs.gxt.ui.client.widget.Container
findItem, getItem, getItemByItemId, getItemCount, getItems, getWidget, indexOf, iterator, removeAll
 
Methods inherited from class com.extjs.gxt.ui.client.widget.BoxComponent
getBounds, getHeight, getHeight, getPosition, getShadow, getSize, getWidth, getWidth, isAutoHeight, isAutoWidth, isDeferHeight, isShim, setAutoHeight, setAutoWidth, setBounds, setBounds, setDeferHeight, setHeight, setHeight, setPagePosition, setPagePosition, setPixelSize, setPosition, setShadow, setShim, setSize, setSize, setWidth, setWidth
 
Methods inherited from class com.extjs.gxt.ui.client.widget.Component
addListener, addStyleName, addWidgetListener, disable, disableEvents, disableTextSelection, el, enable, enableEvents, fireEvent, fireEvent, fireEvent, fly, focus, getBaseStyle, getBorders, getData, getData, getElement, getId, getItemId, getModel, getState, getToolTip, hide, hideToolTip, isEnabled, isRendered, isVisible, removeAllListeners, removeFromParent, removeListener, removeStyleName, removeWidgetListener, render, render, saveState, setBorders, setData, setData, setElement, setEnabled, setEnableState, setId, setIntStyleAttribute, setItemId, setStyleAttribute, setStyleName, setTitle, setToolTip, setToolTip, setVisible, show, toString
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
getParent, isAttached
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getOffsetHeight, getOffsetWidth, getStyleName, getStylePrimaryName, getTitle, isVisible, removeStyleDependentName, setStylePrimaryName, setVisible, sinkEvents, unsinkEvents
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Table

public Table()
Creates a new single select table. A column model must be set before the table is rendered.


Table

public Table(TableColumnModel cm)
Creates a new table.

Parameters:
cm - the column model
Method Detail

add

public boolean add(TableItem item)
Description copied from class: Container
Adds a item to the container. Fires the BeforeAdd event before inserting, then fires the Add event after the widget has been inserted.

Parameters:
item - the item to be added

addTableListener

public void addTableListener(TableListener listener)
Adds a table listener.

Parameters:
listener - thet able listener

getBulkRender

public boolean getBulkRender()
Returns true if bulk rendering is enabled.

Returns:
the bulk rendering state

getColumn

public TableColumn getColumn(int index)
Returns the column at the specified index.

Specified by:
getColumn in interface BaseTable
Parameters:
index - the column index
Returns:
the column

getColumn

public TableColumn getColumn(java.lang.String id)
Returns the column with the given id.

Parameters:
id - the column id
Returns:
the column

getColumnContextMenu

public boolean getColumnContextMenu()
Returns the column context menu enabed state.

Specified by:
getColumnContextMenu in interface BaseTable
Returns:
true if enabled, false otherwise.

getColumnCount

public int getColumnCount()
Returns the number of columns contained in the table.

Returns:
the number of columns

getColumnModel

public TableColumnModel getColumnModel()
Returns the table's column model.

Specified by:
getColumnModel in interface BaseTable
Returns:
the column model

getContextMenu

public Menu getContextMenu()
Description copied from class: Component
Returns the component's context menu. This method is marked protected, subclasses can change access to public to expose the contenxt menu.

Returns:
the context menu

getHighlight

public boolean getHighlight()
Returns true if highlights are enabled.

Returns:
true if mouse overs are enable

getHorizontalScroll

public boolean getHorizontalScroll()
Returns true if horizontal scrolling is enabled

Returns:
the horizontal scroll state

getSelectedItem

public TableItem getSelectedItem()
Description copied from interface: Selectable
Returns the selected item.

Specified by:
getSelectedItem in interface Selectable<TableItem>
Returns:
the selected item

getSelectedItems

public java.util.List<TableItem> getSelectedItems()
Description copied from interface: Selectable
Returns the selected items. For single-select, the last selected item is returned.

Specified by:
getSelectedItems in interface Selectable<TableItem>
Returns:
the selected items

getSelectionMode

public Style.SelectionMode getSelectionMode()

getSelectionModel

public TableSelectionModel getSelectionModel()
Returns the table's selection model.

Returns:
the selection model

getTableHeader

public TableHeader getTableHeader()
Returns the table's header.

Specified by:
getTableHeader in interface BaseTable
Returns:
the table header

getVerticalLines

public boolean getVerticalLines()
Returns true if vertical lines are enabled.

Returns:
the vertical lines state

getView

public TableView getView()
Returns the table's view.

Returns:
the view

insert

public boolean insert(TableItem item,
                      int index)
Description copied from class: Container
Addss a item into the container. Fires the BeforeAdd event before inserting, then fires the Add event after the widget has been inserted.

Parameters:
item - the item to insert
index - the insert location

onBrowserEvent

public void onBrowserEvent(com.google.gwt.user.client.Event event)
Description copied from class: Component
Components delegate event handling to Component.onComponentEvent(ComponentEvent). Sublcasses should not override.

Specified by:
onBrowserEvent in interface com.google.gwt.user.client.EventListener
Overrides:
onBrowserEvent in class Component
Parameters:
event - the dom event

onComponentEvent

public void onComponentEvent(ComponentEvent ce)
Description copied from class: Component
Any events a component receives will be forwarded to this method. Subclasses should override as needed. The Component.onBrowserEvent(com.google.gwt.user.client.Event) method should not be overridden or modified.

Overrides:
onComponentEvent in class Component
Parameters:
ce - the base event

onSelectChange

public void onSelectChange(TableItem item,
                           boolean select)
Description copied from interface: Selectable
Called when the visual state of a item is changed.

Specified by:
onSelectChange in interface Selectable<TableItem>
Parameters:
item - the item
select - the select state

recalculate

public void recalculate()
Description copied from class: Component
Called when the component is in a LayoutContainer and the container's layout executes. This method will not be called on container instances. Default implementation does nothing.

Overrides:
recalculate in class Component

remove

public boolean remove(TableItem item)
Description copied from class: Container
Removes the item from the container. Fires the BeforeRemove event before removing, then fires the Remove event after the widget has been removed.

Parameters:
item - the item to remove
Returns:
true if the item was removed

removeTableLisetener

public void removeTableLisetener(TableListener listener)
Remvoves a table listener.

Parameters:
listener - the table listener

scrollIntoView

public void scrollIntoView(TableItem item)
Description copied from class: Container
Scrolls the item into view.

Overrides:
scrollIntoView in class Container<TableItem>
Parameters:
item - the item

setBulkRender

public void setBulkRender(boolean bulkRender)
True to bulk render the table when first rendered (defaults to true). When true, widget are not supported in table cells.

Parameters:
bulkRender - true for bulk rendering

setColumnContextMenu

public void setColumnContextMenu(boolean columnContextMenu)
Sets whether the table header context menu is displayed (defaults to true).

Parameters:
columnContextMenu - the column context menu sate

setColumnModel

public void setColumnModel(TableColumnModel cm)
Sets the table's column model.

Parameters:
cm - the column model

setContextMenu

public void setContextMenu(Menu menu)
Description copied from class: Component
Sets the component's context menu.

Parameters:
menu - the context menu

setHighlight

public void setHighlight(boolean highlight)
True to highlight the current row (defaults to true).

Parameters:
highlight - the highlight state

setHorizontalScroll

public void setHorizontalScroll(boolean horizontalScroll)
True to display a horizonatal scroll bar when needed (defaults to true).

Parameters:
horizontalScroll - the horizontal scroll state

setSelectedItem

public void setSelectedItem(TableItem item)
Description copied from interface: Selectable
Selects the item. Any existing selections are cleared.

Specified by:
setSelectedItem in interface Selectable<TableItem>
Parameters:
item - the item to select

setSelectedItems

public void setSelectedItems(java.util.List<TableItem> items)
Description copied from interface: Selectable
Selects the items. Only the first item is selected for single-select. Any existing selections are cleared.

Specified by:
setSelectedItems in interface Selectable<TableItem>
Parameters:
items - the items to select

setSelectionMode

public void setSelectionMode(Style.SelectionMode mode)
Sets the table's selection mode.

Parameters:
mode - the selection mode

setSelectionModel

public void setSelectionModel(TableSelectionModel sm)
Sets the table's selection model.

Parameters:
sm - the selection model

setTableHeader

public void setTableHeader(TableHeader header)
Sets the table's header. Should only be called when providing a custom table header. Has no effect if called after the table has been rendered.

Parameters:
header - the table header

setVerticalLines

public void setVerticalLines(boolean verticalLines)
True to display vertical borders on the table data (defaults to false).

Parameters:
verticalLines - true for vertical lines

setView

public void setView(TableView view)
Sets the table's view. Provides a way to provide specialized views. table views.

Parameters:
view - the view

sort

public void sort(int index,
                 Style.SortDir sortDir)
Sorts the table using the specified column index.

Specified by:
sort in interface BaseTable
Parameters:
index - the column index
sortDir - the direction to sort (NONE, ASC, DESC)