com.extjs.gxt.ui.client.widget.grid
Class ColumnModel

java.lang.Object
  extended by com.extjs.gxt.ui.client.event.BaseObservable
      extended by com.extjs.gxt.ui.client.widget.grid.ColumnModel
All Implemented Interfaces:
Observable

public class ColumnModel
extends BaseObservable

This is the default implementation of a ColumnModel.

Events:
WidthChange : ColumnModelEvent(cm, colIndex)
Fires when the width of a column changes.
HeaderChange : ColumnModelEvent(cm, colIndex)
Fires when the text of a header changes.
HiddenChange : ColumnModelEvent(cm, colIndex)
Fires when a column is hidden or "unhidden".
ColumnMove : ColumnModelEvent(cm, colIndex)
Fires when a column is moved.


Constructor Summary
ColumnModel(java.util.List<ColumnConfig> columns)
           
 
Method Summary
 int findColumnIndex(java.lang.String dataIndex)
          Finds the index of the first matching column for the given dataIndex.
 ColumnConfig getColumn(int colIndex)
           
 Style.HorizontalAlignment getColumnAlignment(int colIndex)
          Returns the column's alignment.
 ColumnConfig getColumnById(java.lang.String id)
          Returns the column for a specified id.
 int getColumnCount()
          Returns the column count.
 int getColumnCount(boolean visibleOnly)
          Returns the number of visible columns.
 java.lang.String getColumnHeader(int colIndex)
          Returns the header for the specified column.
 java.lang.String getColumnId(int colIndex)
          Returns the id of the column at the specified index.
 java.lang.String getColumnStyle(int colIndex)
          Returns the column's style.
 java.lang.String getColumnToolTip(int colIndex)
          Returns the tooltip for the specified column.
 int getColumnWidth(int colIndex)
          Returns the column width.
 java.lang.String getDataIndex(int colIndex)
          Returns the data index for the specified column.
 CellEditor getEditor(int colIndex)
          Returns the column's editor.
 int getIndexById(java.lang.String id)
          Returns the index for a specified column id.
 GridCellRenderer getRenderer(int colIndex)
          Returns the cell renderer.
 int getTotalWidth()
          Returns the total width of all columns.
 int getTotalWidth(boolean includeHidden)
          Returns the total width of all columns.
 boolean isCellEditble(int colIndex)
          Returns true if the cell is editable.
 boolean isFixed(int colIndex)
          Returns true if the column can be resized.
 boolean isGroupable(int colIndex)
           
 boolean isHidden(int colIndex)
          Returns true if the column is hidden.
 boolean isMenuDisabled(int colIndex)
          Returns true if the specified column menu is disabled.
 boolean isResizable(int colIndex)
          Returns true if the column can be resized.
 boolean isSortable(int colIndex)
          Returns true if the specified column is sortable.
 void setColumnHeader(int colIndex, java.lang.String header)
          Sets the header for a column.
 void setColumnWidth(int colIndex, int width)
          Sets the column's width.
 void setColumnWidth(int colIndex, int width, boolean supressEvent)
          Sets the column's width.
 void setDataIndex(int colIndex, java.lang.String dataIndex)
          Sets the dataIndex for a column.
 void setEditor(int colIndex, CellEditor editor)
          Sets the editor for the column.
 void setHidden(int colIndex, boolean hidden)
          Sets if a column is hidden.
 
Methods inherited from class com.extjs.gxt.ui.client.event.BaseObservable
addListener, fireEvent, fireEvent, getFiresEvents, hasListeners, hasListeners, removeAllListeners, removeListener, setFiresEvents
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColumnModel

public ColumnModel(java.util.List<ColumnConfig> columns)
Method Detail

findColumnIndex

public int findColumnIndex(java.lang.String dataIndex)
Finds the index of the first matching column for the given dataIndex.

Parameters:
dataIndex - the data index
Returns:
the column index, or -1 if no match was found

getColumn

public ColumnConfig getColumn(int colIndex)

getColumnAlignment

public Style.HorizontalAlignment getColumnAlignment(int colIndex)
Returns the column's alignment.

Parameters:
colIndex - the column index
Returns:
the alignment

getColumnById

public ColumnConfig getColumnById(java.lang.String id)
Returns the column for a specified id.

Parameters:
id - the column id
Returns:
the column

getColumnCount

public int getColumnCount()
Returns the column count.

Returns:
the column count

getColumnCount

public int getColumnCount(boolean visibleOnly)
Returns the number of visible columns.

Returns:
the visible column count

isGroupable

public boolean isGroupable(int colIndex)

getColumnHeader

public java.lang.String getColumnHeader(int colIndex)
Returns the header for the specified column.

Parameters:
colIndex - the column index
Returns:
the header

getColumnId

public java.lang.String getColumnId(int colIndex)
Returns the id of the column at the specified index.

Parameters:
colIndex - the column index
Returns:
the id

getColumnStyle

public java.lang.String getColumnStyle(int colIndex)
Returns the column's style.

Parameters:
colIndex - the column index
Returns:
the column style

getColumnToolTip

public java.lang.String getColumnToolTip(int colIndex)
Returns the tooltip for the specified column.

Parameters:
colIndex - the column index
Returns:
the tooltip

getColumnWidth

public int getColumnWidth(int colIndex)
Returns the column width.

Parameters:
colIndex - the column index
Returns:
the width

getDataIndex

public java.lang.String getDataIndex(int colIndex)
Returns the data index for the specified column.

Parameters:
colIndex - the column index
Returns:
the data index

getEditor

public CellEditor getEditor(int colIndex)
Returns the column's editor.

Parameters:
colIndex - the column index
Returns:
the cell editor

getIndexById

public int getIndexById(java.lang.String id)
Returns the index for a specified column id.

Parameters:
id - the column id
Returns:
the index, or -1 if not found

getRenderer

public GridCellRenderer getRenderer(int colIndex)
Returns the cell renderer.

Parameters:
colIndex - the column index
Returns:
the cell renderer

getTotalWidth

public int getTotalWidth()
Returns the total width of all columns.

Returns:
the total width

getTotalWidth

public int getTotalWidth(boolean includeHidden)
Returns the total width of all columns.

Parameters:
includeHidden - true to include hidden column widths
Returns:
the total

isCellEditble

public boolean isCellEditble(int colIndex)
Returns true if the cell is editable.

Parameters:
colIndex - the column index
Returns:
true if editable

isFixed

public boolean isFixed(int colIndex)
Returns true if the column can be resized.

Parameters:
colIndex - the column index
Returns:
true if fixed

isHidden

public boolean isHidden(int colIndex)
Returns true if the column is hidden.

Parameters:
colIndex - the column index
Returns:
true if hidden

isMenuDisabled

public boolean isMenuDisabled(int colIndex)
Returns true if the specified column menu is disabled.

Parameters:
colIndex - the column index
Returns:
true if disabled

isResizable

public boolean isResizable(int colIndex)
Returns true if the column can be resized.

Parameters:
colIndex - the column index
Returns:
true if resizable

isSortable

public boolean isSortable(int colIndex)
Returns true if the specified column is sortable.

Parameters:
colIndex - the column index
Returns:
true if the column is sortable

setColumnHeader

public void setColumnHeader(int colIndex,
                            java.lang.String header)
Sets the header for a column.

Parameters:
colIndex - the column index
header - the header

setColumnWidth

public void setColumnWidth(int colIndex,
                           int width)
Sets the column's width.

Parameters:
colIndex - the column index
width - the width

setColumnWidth

public void setColumnWidth(int colIndex,
                           int width,
                           boolean supressEvent)
Sets the column's width.

Parameters:
colIndex - the column index
width - the width
supressEvent - true to supress width change event

setDataIndex

public void setDataIndex(int colIndex,
                         java.lang.String dataIndex)
Sets the dataIndex for a column.

Parameters:
colIndex - the column index
dataIndex - the data index

setEditor

public void setEditor(int colIndex,
                      CellEditor editor)
Sets the editor for the column.

Parameters:
colIndex - the column index
editor - the editor

setHidden

public void setHidden(int colIndex,
                      boolean hidden)
Sets if a column is hidden.

Parameters:
colIndex - the column index
hidden - true to hide the column