com.gwtext.client.widgets.grid
Class GridPanel

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.gwtext.client.widgets.Component
              extended by com.gwtext.client.widgets.BoxComponent
                  extended by com.gwtext.client.widgets.Container
                      extended by com.gwtext.client.widgets.Panel
                          extended by com.gwtext.client.widgets.grid.GridPanel
All Implemented Interfaces:
com.google.gwt.user.client.EventListener, com.google.gwt.user.client.ui.HasWidgets, Observable
Direct Known Subclasses:
EditorGridPanel

public class GridPanel
extends Panel

A Grid widget.

Common Problems:


CSS can be used to style or customize the behaviour of headers an cells.
For example, use this to wrap all cell contents globally
 .x-grid3-cell-inner {
      overflow: visible; white-space: normal !important;
 }
 
To wrap cell contents on a certain table only, set an ID to the Grid panel (say company-grid) and then use the CSS
 #company-grid  .x-grid3-cell-inner {
      overflow: visible; white-space: normal !important;
 }
 
To wrap long header titles For all grids
 .x-grid3-hd-inner  {
     overflow: visible; white-space: normal;
 }
 
For specific grid
 #company-grid .x-grid3-hd-inner  {
     overflow: visible; white-space: normal;
 }
 
For specific column
 .x-grid3-hd-company {
      overflow: visible; white-space: normal !important;
 }
 


Field Summary
 
Fields inherited from class com.gwtext.client.widgets.Component
config, id
 
Constructor Summary
GridPanel()
           
GridPanel(com.google.gwt.core.client.JavaScriptObject jsObj)
           
GridPanel(Store store, ColumnModel columnModel)
          Creates a new Grid.
GridPanel(java.lang.String id, int width, int height, Store store, ColumnModel columnModel)
          Creates a new Grid.
 
Method Summary
 void addGridCellListener(GridCellListener listener)
          Add a Grid Cell listener.
 void addGridColumnListener(GridColumnListener listener)
          Add a Grid Column listener.
 void addGridHeaderListener(GridHeaderListener listener)
          Add a Grid Header listener.
 void addGridListener(GridListener listener)
          Add a Grid Cell listener.
 void addGridMouseListener(GridMouseListener listener)
          Add a Grid mouse listener.
 void addGridRowListener(GridRowListener listener)
          Add a Grid row listener.
 void clearSortState(boolean reload)
          Clear the sort state of the grid.
protected  com.google.gwt.core.client.JavaScriptObject create(com.google.gwt.core.client.JavaScriptObject configJS)
           
 ColumnModel getColumnModel()
          Returns the grid's ColumnModel.
protected  com.google.gwt.core.client.JavaScriptObject getConfigPrototype()
           
 java.lang.String getDragDropText()
          Called to get Grid's drag proxy text.
 RowSelectionModel getSelectionModel()
          Returns the Grid's row selection model
 com.google.gwt.core.client.JavaScriptObject getSelectionModelAsJavaScriptObject()
          Returns the Grid's selection model, as a raw JavaScriptObject
 Store getStore()
          Returns the Grid's Store
 GridView getView()
          Returns the grid's GridView object.
 java.lang.String getXType()
          Gets the xtype for this component as registered with ComponentMgr.
 void hideColumn(int colIndex)
          Hides the specified column.
 void hideColumn(java.lang.String colID)
          Hides the specified column.
 void hideColumnHeader()
          Hides the column header of the grid.
protected  void initComponent()
          This template method is called after the Component has been instantiated but before it's rendered.
 void reconfigure(Store store, ColumnModel columnModel)
          Reconfigures the grid to use a different Store and Column Model.
 void render(com.google.gwt.core.client.JavaScriptObject grid)
           
 void setAutoExpandColumn(int autoExpandColumn)
          The id of a column in this grid that should expand to fill unused space.
 void setAutoExpandColumn(java.lang.String autoExpandColumn)
          The id of a column in this grid that should expand to fill unused space.
 void setAutoExpandMax(int autoExpandMax)
          The maximum width the autoExpandColumn can have (if enabled).
 void setAutoExpandMin(int autoExpandMin)
          The minimum width the autoExpandColumn can have (if enabled).
 void setAutoHeight(boolean autoHeight)
          True to fit the height of the grid container to the height of the data.
 void setColumnModel(ColumnModel columnModel)
          The ColumnModel to use when rendering the grid (required).
 void setDdGroup(java.lang.String ddGroup)
          The DD group this GridPanel belongs to (defaults to 'GridDD').
 void setDisableSelection(boolean disableSelection)
          True to disable selections in the grid (defaults to false).
 void setDragDropText(java.lang.String text)
          Sets the Grid's drag drop text
 void setEnableColumnHide(boolean enableColumnHide)
          True to enable hiding of columns with the header context menu.
 void setEnableColumnMove(boolean enableColumnMove)
          True to enable drag and drop reorder of columns.
 void setEnableColumnResize(boolean enableColumnResize)
          True to enable column resize.
 void setEnableDragDrop(boolean enableDragDrop)
          True to enable drag and drop of rows.
 void setEnableHdMenu(boolean enableHdMenu)
          True to enable the drop down button for menu in the headers.
 void setHideColumnHeader(boolean hideColumnHeader)
          Hides the column header of the grid if passed true.
 void setLoadMask(boolean loadMask)
          True to mask the grid while loading.
 void setLoadMask(java.lang.String message)
          Sets the load mask message for the grid.
 void setLoadMask(java.lang.String message, java.lang.String messageCls)
          Sets the LoadMask to mask the grid while loading.
 void setMaxRowsToMeasure(int maxRowsToMeasure)
          If autoSizeColumns is on, maxRowsToMeasure can be used to limit the number of rows measured to get a columns size.
 void setMinColumnWidth(int minColumnWidth)
          The minimum width a column can be resized to.
 void setMonitorWindowResize(boolean monitorWindowResize)
          True to autoSize the grid when the window resizes.
 void setSelectionModel(AbstractSelectionModel selectionModel)
          Set the GridPanel's selection model.
 void setStore(Store store)
          The Store the grid should use as its data source (required).
 void setStripeRows(boolean stripeRows)
          True to stripe the rows.
 void setTrackMouseOver(boolean trackMouseOver)
          True to highlight rows when the mouse is over.
 void setView(GridView view)
          Sets the GridView used by the grid.
 void showColumn(int colIndex)
          Shows the specified column.
 void showColumn(java.lang.String colID)
          Show the specified column.
 void stripeRows(boolean stripeRows)
          True to stripe the rows.
 
Methods inherited from class com.gwtext.client.widgets.Panel
addButton, addListener, addTool, collapse, collapse, expand, expand, getBaseCls, getBody, getBodyStyle, getBodyWrap, getBottomToolbar, getCollapsedCls, getCollapseFirst, getFloating, getFooter, getFrameHeight, getFrameWidth, getHeader, getHtml, getIconCls, getInnerHeight, getInnerWidth, getMinButtonWidth, getShadowOffset, getTabCls, getTitle, getTopToolbar, getUpdateManager, isAnimCollapse, isAutoScroll, isBodyBorder, isBorder, isClosable, isCollapsed, isCollapsible, isFrame, isHeader, isHeaderAsText, isHideCollapseTool, isMaskDisabled, isShadow, isShim, isTitleCollapse, load, load, setAnimCollapse, setAutoLoad, setAutoLoad, setAutoScroll, setBaseCls, setBodyBorder, setBodyStyle, setBorder, setBottomToolbar, setBottomToolbar, setBottomToolbar, setButtonAlign, setButtons, setClosable, setCollapsed, setCollapsedCls, setCollapseFirst, setCollapsible, setContentEl, setDraggable, setFloating, setFooter, setFrame, setHeader, setHeaderAsText, setHideCollapseTool, setHtml, setIconCls, setMargins, setMargins, setMaskDisabled, setMinButtonWidth, setPaddings, setPaddings, setShadow, setShadow, setShadowOffset, setShim, setTabCls, setTitle, setTitle, setTitleCollapse, setTools, setTopToolbar, setTopToolbar, setTopToolbar, toggleCollapse, toggleCollapse
 
Methods inherited from class com.gwtext.client.widgets.Container
add, add, add, add, addListener, bubble, cascade, clear, doLayout, doLayout, findBy, findByID, findByType, getActiveItem, getActiveItemID, getAutoDestroy, getBufferResize, getComponent, getComponent, getComponents, getHideBorders, getItems, getLayout, getMonitorResize, insert, iterator, remove, remove, remove, remove, removeAll, removeAll, setActiveItem, setActiveItemID, setAutoDestroy, setBufferResize, setDefaults, setHideBorders, setLayout, setMonitorResize
 
Methods inherited from class com.gwtext.client.widgets.BoxComponent
addListener, doOnRender, doOnRender, getAutoHeight, getAutoWidth, getBox, getBox, getHeight, getPosition, getPosition, getSize, getWidth, setAutoWidth, setHeight, setHeight, setPagePosition, setPosition, setSize, setSize, setWidth, setWidth, syncSize, updateBox
 
Methods inherited from class com.gwtext.client.widgets.Component
addClass, addClassCreated, addEvent, addEvents, addListener, addListener, addListener, addPlugin, addStyleDependentName, addStyleName, afterRender, beforeDestroy, check, checkExtVer, cloneComponent, cloneComponent, cloneConfig, destroy, disable, enable, equals, error, findParentBy, findParentByType, fireEvent, focus, focus, focus, getApplyTo, getAttribute, getAttributeAsBoolean, getAttributeAsFloat, getAttributeAsInt, getAttributeAsJavaScriptObject, getAutoShow, getCls, getComponentJS, getConfig, getConfigAsString, getCtCls, getDisabledClass, getEl, getElement, getElement, getElement, getHideMode, getHideParent, getId, getItemId, getJsObj, getOffsetHeight, getOffsetWidth, getOrCreateJsObj, getOwnerContainer, getRenderTo, getStateEvents, getStateId, getXTypes, hashCode, hide, isCreated, isDisabled, isHidden, isRendered, isVisible, isXType, isXType, onDestroy, purgeListeners, removeClass, removeStyleDependentName, removeStyleName, render, render, render, render, render, render, resumeEvents, setApplyTo, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAutoEl, setAutoEl, setAutoShow, setCls, setCtCls, setDisabled, setDisabledClass, setEl, setEl, setElement, setHideMode, setHideParent, setId, setRenderTo, setRenderToID, setStateEvents, setStateId, setStyle, setStyle, setStyleName, setStylePrimaryName, setVisible, show, suspendEvents, toString
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
doAttachChildren, doDetachChildren, getParent, isAttached, onAttach, onBrowserEvent, onDetach, onLoad, onUnload, removeFromParent
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
getAbsoluteLeft, getAbsoluteTop, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, isVisible, setPixelSize, setStyleName, setStyleName, setStylePrimaryName, setVisible, sinkEvents, unsinkEvents
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GridPanel

public GridPanel(com.google.gwt.core.client.JavaScriptObject jsObj)

GridPanel

public GridPanel()

GridPanel

public GridPanel(Store store,
                 ColumnModel columnModel)
Creates a new Grid.

Parameters:
store - the Grid's data store
columnModel - the Grid's column model

GridPanel

public GridPanel(java.lang.String id,
                 int width,
                 int height,
                 Store store,
                 ColumnModel columnModel)
Creates a new Grid.

Parameters:
id - the Grid ID
width - the Grid width
height - the Grid height
store - the Grid's data store
columnModel - the Grid's column model
Method Detail

getConfigPrototype

protected com.google.gwt.core.client.JavaScriptObject getConfigPrototype()
Overrides:
getConfigPrototype in class Panel

getXType

public java.lang.String getXType()
Description copied from class: Component
Gets the xtype for this component as registered with ComponentMgr. For a list of all available xtypes, see the Component javadocs.

 
 

TextField field = new TextField(); field.getXType() returns "textfield"

Overrides:
getXType in class Panel
Returns:
the xtype

create

protected com.google.gwt.core.client.JavaScriptObject create(com.google.gwt.core.client.JavaScriptObject configJS)
Overrides:
create in class Panel

initComponent

protected void initComponent()
Description copied from class: Component
This template method is called after the Component has been instantiated but before it's rendered. Subclasses can override it to provide any "constructor" type logic thats desired/

Overrides:
initComponent in class Component

clearSortState

public void clearSortState(boolean reload)
Clear the sort state of the grid. This resets the sort arrow indicators on the Grid

Parameters:
reload - true to reload the store after clearing the sort state

getColumnModel

public ColumnModel getColumnModel()
Returns the grid's ColumnModel.

Returns:
the column model

getStore

public Store getStore()
Returns the Grid's Store

Returns:
the Grids Store

getDragDropText

public java.lang.String getDragDropText()
Called to get Grid's drag proxy text.

Returns:
the grids drag drop text

setDragDropText

public void setDragDropText(java.lang.String text)
Sets the Grid's drag drop text

Parameters:
text - the drag drop text

getSelectionModel

public RowSelectionModel getSelectionModel()
Returns the Grid's row selection model

Returns:
the selection model

getSelectionModelAsJavaScriptObject

public com.google.gwt.core.client.JavaScriptObject getSelectionModelAsJavaScriptObject()
Returns the Grid's selection model, as a raw JavaScriptObject

Returns:
the selection model's raw JavaScriptObject (null if called before grid creation or calling setSelectionModel(...) )

getView

public GridView getView()
Returns the grid's GridView object.

Returns:
grid view

hideColumn

public void hideColumn(java.lang.String colID)
Hides the specified column.

Parameters:
colID - the column ID

hideColumn

public void hideColumn(int colIndex)
Hides the specified column.

Parameters:
colIndex - the column index

hideColumnHeader

public void hideColumnHeader()
Hides the column header of the grid.


render

public void render(com.google.gwt.core.client.JavaScriptObject grid)

reconfigure

public void reconfigure(Store store,
                        ColumnModel columnModel)
Reconfigures the grid to use a different Store and Column Model. The View will be bound to the new objects and refreshed.

Parameters:
store - the new Store
columnModel - the new ColumnModel

setLoadMask

public void setLoadMask(java.lang.String message)
Sets the load mask message for the grid.

Parameters:
message - the load mask text

showColumn

public void showColumn(java.lang.String colID)
Show the specified column.

Parameters:
colID - the column ID

showColumn

public void showColumn(int colIndex)
Shows the specified column.

Parameters:
colIndex - the column index

addGridCellListener

public void addGridCellListener(GridCellListener listener)
Add a Grid Cell listener.

Parameters:
listener - the listener

addGridColumnListener

public void addGridColumnListener(GridColumnListener listener)
Add a Grid Column listener.

Parameters:
listener - the listener

addGridHeaderListener

public void addGridHeaderListener(GridHeaderListener listener)
Add a Grid Header listener.

Parameters:
listener - the listener

addGridListener

public void addGridListener(GridListener listener)
Add a Grid Cell listener.

Parameters:
listener - the listener

addGridMouseListener

public void addGridMouseListener(GridMouseListener listener)
Add a Grid mouse listener.

Parameters:
listener - the listener

addGridRowListener

public void addGridRowListener(GridRowListener listener)
Add a Grid row listener.

Parameters:
listener - the listener

setDdGroup

public void setDdGroup(java.lang.String ddGroup)
                throws java.lang.IllegalStateException
The DD group this GridPanel belongs to (defaults to 'GridDD').

Parameters:
ddGroup - the DD group
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setMinColumnWidth

public void setMinColumnWidth(int minColumnWidth)
                       throws java.lang.IllegalStateException
The minimum width a column can be resized to. Default is 25.

Parameters:
minColumnWidth - the min column width
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setMonitorWindowResize

public void setMonitorWindowResize(boolean monitorWindowResize)
                            throws java.lang.IllegalStateException
True to autoSize the grid when the window resizes. Default is true.

Parameters:
monitorWindowResize - true to monitor window resize
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setMaxRowsToMeasure

public void setMaxRowsToMeasure(int maxRowsToMeasure)
                         throws java.lang.IllegalStateException
If autoSizeColumns is on, maxRowsToMeasure can be used to limit the number of rows measured to get a columns size. Default is 0 (all rows).

Parameters:
maxRowsToMeasure - max rows to measure
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setTrackMouseOver

public void setTrackMouseOver(boolean trackMouseOver)
                       throws java.lang.IllegalStateException
True to highlight rows when the mouse is over. Default is true.

Parameters:
trackMouseOver - true to highlight rows when mouse over
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setEnableHdMenu

public void setEnableHdMenu(boolean enableHdMenu)
                     throws java.lang.IllegalStateException
True to enable the drop down button for menu in the headers.

Parameters:
enableHdMenu - true to enable the drop down button for menu in the headers.
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setEnableColumnResize

public void setEnableColumnResize(boolean enableColumnResize)
                           throws java.lang.IllegalStateException
True to enable column resize.

Parameters:
enableColumnResize - true to enable column resize
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setEnableDragDrop

public void setEnableDragDrop(boolean enableDragDrop)
                       throws java.lang.IllegalStateException
True to enable drag and drop of rows. Default is false.

Parameters:
enableDragDrop - true to enable drag drop of rows
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setEnableColumnMove

public void setEnableColumnMove(boolean enableColumnMove)
                         throws java.lang.IllegalStateException
True to enable drag and drop reorder of columns. Default is true.

Parameters:
enableColumnMove - true to enable column move
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setEnableColumnHide

public void setEnableColumnHide(boolean enableColumnHide)
                         throws java.lang.IllegalStateException
True to enable hiding of columns with the header context menu. Default is true

Parameters:
enableColumnHide - true to enable column hide
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setStripeRows

public void setStripeRows(boolean stripeRows)
                   throws java.lang.IllegalStateException
True to stripe the rows. Default is true.

Parameters:
stripeRows - true to stripe rows
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setSelectionModel

public void setSelectionModel(AbstractSelectionModel selectionModel)
                       throws java.lang.IllegalStateException
Set the GridPanel's selection model.

Parameters:
selectionModel - the selection model/
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setAutoHeight

public void setAutoHeight(boolean autoHeight)
                   throws java.lang.IllegalStateException
True to fit the height of the grid container to the height of the data. Default is false.

Overrides:
setAutoHeight in class BoxComponent
Parameters:
autoHeight - true to fit the height of the grid container to the height of the data
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setAutoExpandColumn

public void setAutoExpandColumn(java.lang.String autoExpandColumn)
                         throws java.lang.IllegalStateException
The id of a column in this grid that should expand to fill unused space. This id can not be 0. Default is false.
Note : You must pass the ID of the ColumnConfig, and not the dataIndex of the corresponding ColumnConfig.

Parameters:
autoExpandColumn - the column id
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered
See Also:
ColumnConfig.setId(String)

setAutoExpandColumn

public void setAutoExpandColumn(int autoExpandColumn)
                         throws java.lang.IllegalStateException
The id of a column in this grid that should expand to fill unused space. This id can not be 0. Default is false.

Parameters:
autoExpandColumn - the column id
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setAutoExpandMin

public void setAutoExpandMin(int autoExpandMin)
                      throws java.lang.IllegalStateException
The minimum width the autoExpandColumn can have (if enabled). Default is 50.

Parameters:
autoExpandMin - the min expand value
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setAutoExpandMax

public void setAutoExpandMax(int autoExpandMax)
                      throws java.lang.IllegalStateException
The maximum width the autoExpandColumn can have (if enabled). Default is 1000.

Parameters:
autoExpandMax - the max expand value
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setDisableSelection

public void setDisableSelection(boolean disableSelection)
                         throws java.lang.IllegalStateException
True to disable selections in the grid (defaults to false). - ignored a SelectionModel is specified

Parameters:
disableSelection - true to disable selections in the grid (defaults to false). - ignored a SelectionModel is specified
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setHideColumnHeader

public void setHideColumnHeader(boolean hideColumnHeader)
Hides the column header of the grid if passed true.

Parameters:
hideColumnHeader - true to hide the column headers

setView

public void setView(GridView view)
             throws java.lang.IllegalStateException
Sets the GridView used by the grid.

Parameters:
view - the grid view
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setLoadMask

public void setLoadMask(boolean loadMask)
                 throws java.lang.IllegalStateException
True to mask the grid while loading. Default is false.

Parameters:
loadMask - true to mask grid
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setLoadMask

public void setLoadMask(java.lang.String message,
                        java.lang.String messageCls)
                 throws java.lang.IllegalStateException
Sets the LoadMask to mask the grid while loading. Default is disable masking.

Parameters:
message - the load mask message
messageCls - the load mask message CSS class
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setStore

public void setStore(Store store)
              throws java.lang.IllegalStateException
The Store the grid should use as its data source (required).

Parameters:
store - the store
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setColumnModel

public void setColumnModel(ColumnModel columnModel)
                    throws java.lang.IllegalStateException
The ColumnModel to use when rendering the grid (required).

Parameters:
columnModel - the grids column model
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

stripeRows

public void stripeRows(boolean stripeRows)
                throws java.lang.IllegalStateException
True to stripe the rows. Default is false.

Parameters:
stripeRows - true to stripe the rows. Default is false.
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered