This is the default implementation of a ColumnModel used by the Grid. It defines
the columns in the grid.
Usage:
var sort = YAHOO.ext.grid.DefaultColumnModel.sortTypes;
var myColumns = [
{header: "Ticker", width: 60, sortable: true, sortType: sort.asUCString},
{header: "Company Name", width: 150, sortable: true, sortType: sort.asUCString},
{header: "Market Cap.", width: 100, sortable: true, sortType: sort.asFloat},
{header: "$ Sales", width: 100, sortable: true, sortType: sort.asFloat, renderer: money},
{header: "Employees", width: 100, sortable: true, sortType: sort.asFloat}
];
var colModel = new YAHOO.ext.grid.DefaultColumnModel(myColumns);
|
DefaultColumnModel(Object config ) |
DefaultColumnModel |
|
|
addListener(String eventName , Function handler , [Object scope ], [boolean override ]) : void |
Observable |
Appends an event handler to this component |
|
bufferedListener(String eventName , Function handler , [Object scope ], [Number millis ]) : Function |
Observable |
Appends an event handler to this component that is buffered. If the event is triggered more than once
in the specifie... |
|
delayedListener(String eventName , Function handler , [Object scope ], [Number delay ]) : Function |
Observable |
Appends an event handler to this component that is delayed the specified number of milliseconds. This
is useful for e... |
|
fireEvent(String eventName , Object... args ) : Boolean |
Observable |
Fires the specified event with the passed parameters (minus the event name). |
|
getCellEditor(Number colIndex , Number rowIndex ) : Object |
DefaultColumnModel |
Returns the editor defined for the cell/column. |
|
getColumnCount() : Number |
DefaultColumnModel |
Returns the number of columns. |
|
getColumnHeader(Number col ) : String |
DefaultColumnModel |
Returns the header for the specified column. |
|
getColumnTooltip(Number col ) : String |
DefaultColumnModel |
Returns the tooltip for the specified column. |
|
getColumnWidth(Number col ) : Number |
DefaultColumnModel |
Returns the width for the specified column. |
|
getDataIndex(Number col ) : Number |
DefaultColumnModel |
Returns the dataIndex for the specified column. |
|
getRenderer(Number col ) : Function |
DefaultColumnModel |
Returns the rendering (formatting) function defined for the column. |
|
getSortType(Number col ) : Function |
DefaultColumnModel |
Returns the sorting comparison function defined for the column (defaults to sortTypes.none). |
|
getTotalWidth(Boolean includeHidden ) : Number |
DefaultColumnModel |
Returns the total width of all columns. |
|
isCellEditable(Number colIndex , Number rowIndex ) : Boolean |
DefaultColumnModel |
Returns true if the cell is editable. |
|
isFixed() : void |
DefaultColumnModel |
Returns true if the column width cannot be changed |
|
isHidden(Number colIndex ) : Boolean |
DefaultColumnModel |
Returns true if the column is hidden. |
|
isResizable() : Boolean |
DefaultColumnModel |
Returns true if the column cannot be resized |
|
isSortable(Number col ) : Boolean |
DefaultColumnModel |
Returns true if the specified column is sortable. |
|
on(String eventName , Function handler , [Object scope ], [boolean override ]) : void |
Observable |
Appends an event handler to this element (shorthand for addListener) |
|
purgeListeners() : void |
Observable |
Removes all listeners for this object |
|
removeListener(String eventName , Function handler , [Object scope ]) : void |
Observable |
Removes a listener |
|
setColumnHeader(Number col , String header ) : void |
DefaultColumnModel |
Sets the header for a column. |
|
setColumnTooltip(Number col , String tooltip ) : void |
DefaultColumnModel |
Sets the tooltip for a column. |
|
setColumnWidth(Number col , Number width ) : void |
DefaultColumnModel |
Sets the width for a column. |
|
setDataIndex(Number col , Number dataIndex ) : void |
DefaultColumnModel |
Sets the dataIndex for a column. |
|
setEditable(Number col , Boolean editable ) : void |
DefaultColumnModel |
Sets if a column is editable. |
|
setEditor(Number col , Object editor ) : void |
DefaultColumnModel |
Sets the editor for a column. |
|
setHidden(Number colIndex ) : void |
DefaultColumnModel |
Sets if a column is hidden. |
|
setRenderer(Number col , Function fn ) : void |
DefaultColumnModel |
Sets the rendering (formatting) function for a column. |
|
setSortType(Number col , Function fn ) : void |
DefaultColumnModel |
Sets the sorting comparison function for a column. |
config
public Object config
The config passed into the constructor
This property is defined by DefaultColumnModel.
defaultSortable
public Boolean defaultSortable
Default sortable of columns which have no sortable specified (defaults to false)
This property is defined by DefaultColumnModel.
defaultWidth
public Number defaultWidth
The width of columns which have no width specified (defaults to 100)
This property is defined by DefaultColumnModel.
sortTypes<static>
public Object sortTypes<static>
<static> Defines the default sorting (casting?) comparison functions used when sorting data:
sortTypes.none - sorts data as it is without casting or parsing (the default)
sortTypes.asUCString - case insensitive string
sortTypes.asDate - attempts to parse data as a date
sortTypes.asFloat
sortTypes.asInt
This property is defined by DefaultColumnModel.
addListener
public function addListener(String eventName
, Function handler
, [Object scope
], [boolean override
])
Appends an event handler to this component
Parameters:
eventName
: StringThe type of event to listen for
handler
: FunctionThe method the event invokes
scope
: Object(optional) The scope (this object) for the handler
override
: boolean(optional) If true, scope becomes the scope
Returns:
bufferedListener
public function bufferedListener(String eventName
, Function handler
, [Object scope
], [Number millis
])
Appends an event handler to this component that is buffered. If the event is triggered more than once
in the specified time-frame, only the last one actually fires.
Parameters:
eventName
: StringThe type of event to listen for
handler
: FunctionThe method the event invokes
scope
: Object(optional) The scope (this object) for the handler
millis
: Number(optional) The number of milliseconds to buffer (defaults to 250)
Returns:
delayedListener
public function delayedListener(String eventName
, Function handler
, [Object scope
], [Number delay
])
Appends an event handler to this component that is delayed the specified number of milliseconds. This
is useful for events that modify the DOM and need to wait for the browser to catch up.
Parameters:
eventName
: StringThe type of event to listen for
handler
: FunctionThe method the event invokes
scope
: Object(optional) The scope (this object) for the handler
delay
: Number(optional) The number of milliseconds to delay (defaults to 1 millisecond)
Returns:
fireEvent
public function fireEvent(String eventName
, Object... args
)
Fires the specified event with the passed parameters (minus the event name).
getCellEditor
public function getCellEditor(Number colIndex
, Number rowIndex
)
Returns the editor defined for the cell/column.
Parameters:
colIndex
: NumberThe column index
rowIndex
: NumberThe row index
Returns:
This method is defined by DefaultColumnModel.
getColumnCount
public function getColumnCount()
Returns the number of columns.
This method is defined by DefaultColumnModel.
getColumnHeader
public function getColumnHeader(Number col
)
Returns the header for the specified column.
Parameters:
col
: NumberThe column index
Returns:
This method is defined by DefaultColumnModel.
getColumnTooltip
public function getColumnTooltip(Number col
)
Returns the tooltip for the specified column.
Parameters:
col
: NumberThe column index
Returns:
This method is defined by DefaultColumnModel.
getColumnWidth
public function getColumnWidth(Number col
)
Returns the width for the specified column.
Parameters:
col
: NumberThe column index
Returns:
This method is defined by DefaultColumnModel.
getDataIndex
public function getDataIndex(Number col
)
Returns the dataIndex for the specified column.
Parameters:
col
: NumberThe column index
Returns:
This method is defined by DefaultColumnModel.
getRenderer
public function getRenderer(Number col
)
Returns the rendering (formatting) function defined for the column.
Parameters:
col
: NumberThe column index
Returns:
This method is defined by DefaultColumnModel.
getSortType
public function getSortType(Number col
)
Returns the sorting comparison function defined for the column (defaults to sortTypes.none).
Parameters:
col
: NumberThe column index
Returns:
This method is defined by DefaultColumnModel.
getTotalWidth
public function getTotalWidth(Boolean includeHidden
)
Returns the total width of all columns.
This method is defined by DefaultColumnModel.
isCellEditable
public function isCellEditable(Number colIndex
, Number rowIndex
)
Returns true if the cell is editable.
Parameters:
colIndex
: NumberThe column index
rowIndex
: NumberThe row index
Returns:
This method is defined by DefaultColumnModel.
isFixed
public function isFixed()
Returns true if the column width cannot be changed
This method is defined by DefaultColumnModel.
isHidden
public function isHidden(Number colIndex
)
Returns true if the column is hidden.
Parameters:
colIndex
: NumberThe column index
Returns:
This method is defined by DefaultColumnModel.
isResizable
public function isResizable()
Returns true if the column cannot be resized
This method is defined by DefaultColumnModel.
isSortable
public function isSortable(Number col
)
Returns true if the specified column is sortable.
Parameters:
col
: NumberThe column index
Returns:
This method is defined by DefaultColumnModel.
on
public function on(String eventName
, Function handler
, [Object scope
], [boolean override
])
Appends an event handler to this element (shorthand for addListener)
Parameters:
eventName
: StringThe type of event to listen for
handler
: FunctionThe method the event invokes
scope
: Object(optional) The scope (this object) for the handler
override
: boolean(optional) If true, scope becomes the scope
Returns:
purgeListeners
public function purgeListeners()
Removes all listeners for this object
removeListener
public function removeListener(String eventName
, Function handler
, [Object scope
])
setColumnHeader
public function setColumnHeader(Number col
, String header
)
Sets the header for a column.
Parameters:
col
: NumberThe column index
header
: StringThe new header
Returns:
This method is defined by DefaultColumnModel.
setColumnTooltip
public function setColumnTooltip(Number col
, String tooltip
)
Sets the tooltip for a column.
Parameters:
col
: NumberThe column index
tooltip
: StringThe new tooltip
Returns:
This method is defined by DefaultColumnModel.
setColumnWidth
public function setColumnWidth(Number col
, Number width
)
Sets the width for a column.
Parameters:
col
: NumberThe column index
width
: NumberThe new width
Returns:
This method is defined by DefaultColumnModel.
setDataIndex
public function setDataIndex(Number col
, Number dataIndex
)
Sets the dataIndex for a column.
Parameters:
col
: NumberThe column index
dataIndex
: NumberThe new dataIndex
Returns:
This method is defined by DefaultColumnModel.
setEditable
public function setEditable(Number col
, Boolean editable
)
Sets if a column is editable.
This method is defined by DefaultColumnModel.
setEditor
public function setEditor(Number col
, Object editor
)
Sets the editor for a column.
Parameters:
col
: NumberThe column index
editor
: ObjectThe editor object
Returns:
This method is defined by DefaultColumnModel.
setHidden
public function setHidden(Number colIndex
)
Sets if a column is hidden.
Parameters:
colIndex
: NumberThe column index
Returns:
This method is defined by DefaultColumnModel.
setRenderer
public function setRenderer(Number col
, Function fn
)
Sets the rendering (formatting) function for a column.
Parameters:
col
: NumberThe column index
fn
: Function
Returns:
This method is defined by DefaultColumnModel.
setSortType
public function setSortType(Number col
, Function fn
)
Sets the sorting comparison function for a column.
Parameters:
col
: NumberThe column index
fn
: Function
Returns:
This method is defined by DefaultColumnModel.