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.


Field Summary
protected  java.util.List<ColumnConfig> configs
           
protected  Grid<ModelData> grid
           
protected  java.util.List<HeaderGroupConfig> groups
           
protected  java.util.List<AggregationRowConfig<?>> rows
           
 
Constructor Summary
ColumnModel(java.util.List<ColumnConfig> columns)
          Creates a new column model.
 
Method Summary
 void addAggregationRow(AggregationRowConfig<?> row)
          Adds an aggregation row config to the column model.
 void addHeaderGroup(int row, int column, HeaderGroupConfig config)
          Adds a group to the column model.
 int findColumnIndex(java.lang.String dataIndex)
          Finds the index of the first matching column for the given dataIndex.
 AggregationRowConfig<?> getAggregationRow(int rowIndex)
          Returns the aggregation row.
 java.util.List<AggregationRowConfig<?>> getAggregationRows()
          Returns the aggregation rows.
 ColumnConfig getColumn(int colIndex)
          Returns the column at the given index.
 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.util.List<ColumnConfig> getColumns()
          Returns the column configs.
 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.
protected  HeaderGroupConfig getGroup(int row, int column)
           
 java.util.List<HeaderGroupConfig> getHeaderGroups()
          Returns the header groups.
 int getIndexById(java.lang.String id)
          Returns the index for a specified column id.
 GridCellRenderer<ModelData> 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.
protected  boolean hasGroup(int row, int column)
           
 int indexOf(ColumnConfig column)
          Returns the index of the column.
 boolean isCellEditable(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)
          Returns true if the column is groupable.
 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 moveColumn(int oldIndex, int newIndex)
          Moves a column.
 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, callListener, fireEvent, fireEvent, getFiresEvents, getListeners, hasActiveEvent, hasListeners, hasListeners, removeAllListeners, removeListener, setFiresEvents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

configs

protected java.util.List<ColumnConfig> configs

grid

protected Grid<ModelData> grid

groups

protected java.util.List<HeaderGroupConfig> groups

rows

protected java.util.List<AggregationRowConfig<?>> rows
Constructor Detail

ColumnModel

public ColumnModel(java.util.List<ColumnConfig> columns)
Creates a new column model.

Parameters:
columns - the columns
Method Detail

addAggregationRow

public void addAggregationRow(AggregationRowConfig<?> row)
Adds an aggregation row config to the column model.

Parameters:
row - the aggregation row

addHeaderGroup

public void addHeaderGroup(int row,
                           int column,
                           HeaderGroupConfig config)
Adds a group to the column model.

Parameters:
row - the row
column - the column
config - the header group config

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

getAggregationRow

public AggregationRowConfig<?> getAggregationRow(int rowIndex)
Returns the aggregation row.

Parameters:
rowIndex - the row index
Returns:
the aggregation row

getAggregationRows

public java.util.List<AggregationRowConfig<?>> getAggregationRows()
Returns the aggregation rows.

Returns:
the aggregation rows

getColumn

public ColumnConfig getColumn(int colIndex)
Returns the column at the given index.

Parameters:
colIndex - the column index
Returns:
the column or null

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

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

getColumns

public java.util.List<ColumnConfig> getColumns()
Returns the column configs.

Returns:
the column configs

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

getHeaderGroups

public java.util.List<HeaderGroupConfig> getHeaderGroups()
Returns the header groups.

Returns:
the header groups

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<ModelData> 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

indexOf

public int indexOf(ColumnConfig column)
Returns the index of the column.

Parameters:
column - the column
Returns:
the column index

isCellEditable

public boolean isCellEditable(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

isGroupable

public boolean isGroupable(int colIndex)
Returns true if the column is groupable. Applies when using a GroupingView.

Parameters:
colIndex - the column index
Returns:
true if the column is groupable.

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

moveColumn

public void moveColumn(int oldIndex,
                       int newIndex)
Moves a column.

Parameters:
oldIndex - the column index
newIndex - the new column index

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 suppress 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

getGroup

protected HeaderGroupConfig getGroup(int row,
                                     int column)

hasGroup

protected boolean hasGroup(int row,
                           int column)