Package: | Ext.grid |
Class: | ColumnModel |
Extends: | Observable |
Defined In: | ColumnModel.js |
var colModel = new Ext.grid.ColumnModel([
{header: "Ticker", width: 60, sortable: true, locked: true},
{header: "Company Name", width: 150, sortable: true},
{header: "Market Cap.", width: 100, sortable: true},
{header: "$ Sales", width: 100, sortable: true, renderer: money},
{header: "Employees", width: 100, sortable: true, resizable: false}
]);
The config options listed for this class, are options which may appear in each individual column definition.
属性 | 定义对象 | |
---|---|---|
config : Object | ColumnModel | |
The config passed into the constructor | ||
defaultSortable : Boolean | ColumnModel | |
Default sortable of columns which have no sortable specified (defaults to false) | ||
defaultWidth : Number | ColumnModel | |
The width of columns which have no width specified (defaults to 100) |
方法 | 定义对象 | |
---|---|---|
ColumnModel(Object config ) |
ColumnModel | |
addEvents(Object object ) : void |
Observable | |
将对象中没有的事件从给出的对象中复制过来。 | ||
addListener(String eventName , Function handler , [Object scope ], [Object options ]) : void |
Observable | |
为该组件加入事件处理器函数 | ||
fireEvent(String eventName , Object... args ) : Boolean |
Observable | |
触发指定的事件, 并将参数传入(至少要有事件名称)。 | ||
getCellEditor(Number colIndex , Number rowIndex ) : Object |
ColumnModel | |
Returns the editor defined for the cell/column. | ||
getColumnCount() : Number | ColumnModel | |
Returns the number of columns. | ||
getColumnHeader(Number col ) : String |
ColumnModel | |
Returns the header for the specified column. | ||
getColumnId(Number index ) : String |
ColumnModel | |
* Returns the id of the column at the specified index | ||
getColumnTooltip(Number col ) : String |
ColumnModel | |
Returns the tooltip for the specified column. | ||
getColumnWidth(Number col ) : Number |
ColumnModel | |
Returns the width for the specified column. | ||
getDataIndex(Number col ) : Number |
ColumnModel | |
Returns the dataIndex for the specified column. | ||
getRenderer(Number col ) : Function |
ColumnModel | |
Returns the rendering (formatting) function defined for the column. | ||
getTotalWidth(Boolean includeHidden ) : Number |
ColumnModel | |
Returns the total width of all columns. | ||
hasListener(String eventName ) : Boolean |
Observable | |
检查该对象是否拥有指定事件的侦听器 | ||
isCellEditable(Number colIndex , Number rowIndex ) : Boolean |
ColumnModel | |
Returns true if the cell is editable. | ||
isFixed() : void | ColumnModel | |
Returns true if the column width cannot be changed | ||
isHidden(Number colIndex ) : Boolean |
ColumnModel | |
Returns true if the column is hidden. | ||
isResizable() : Boolean | ColumnModel | |
Returns true if the column cannot be resized | ||
isSortable(Number col ) : Boolean |
ColumnModel | |
Returns true if the specified column is sortable. | ||
on(String eventName , Function handler , [Object options ]) : void |
Observable | |
为该组件加入事件处理器函数, addListener 的简写方式 | ||
purgeListeners() : void | Observable | |
从对象身上移除所有的侦听器 | ||
removeListener(String eventName , Function handler , [Object scope ]) : void |
Observable | |
移除侦听器 | ||
setColumnHeader(Number col , String header ) : void |
ColumnModel | |
Sets the header for a column. | ||
setColumnTooltip(Number col , String tooltip ) : void |
ColumnModel | |
Sets the tooltip for a column. | ||
setColumnWidth(Number col , Number width ) : void |
ColumnModel | |
Sets the width for a column. | ||
setDataIndex(Number col , Number dataIndex ) : void |
ColumnModel | |
Sets the dataIndex for a column. | ||
setEditable(Number col , Boolean editable ) : void |
ColumnModel | |
Sets if a column is editable. | ||
setEditor(Number col , Object editor ) : void |
ColumnModel | |
Sets the editor for a column. | ||
setHidden(Number colIndex , Boolean hidden ) : void |
ColumnModel | |
Sets if a column is hidden. | ||
setRenderer(Number col , Function fn ) : void |
ColumnModel | |
Sets the rendering (formatting) function for a column. | ||
un(String eventName , Function handler , [Object scope ]) : void |
Observable | |
移除侦听器, removeListener 的简写方式 |
事件 | 定义对象 | |
---|---|---|
columlockchange : (ColumnModel this , Number colIndex , Boolean locked ) |
ColumnModel | |
Fires when a column's locked state is changed | ||
columnmoved : (ColumnModel this , Number oldIndex , Number newIndex ) |
ColumnModel | |
Fires when a column is moved | ||
headerchange : (ColumnModel this , Number columnIndex , Number newText ) |
ColumnModel | |
Fires when the text of a header changes | ||
hiddenchange : (ColumnModel this , Number columnIndex , Number hidden ) |
ColumnModel | |
Fires when a column is hidden or "unhidden" | ||
widthchange : (ColumnModel this , Number columnIndex , Number newWidth ) |
ColumnModel | |
Fires when the width of a column changes |
public Object config
public Boolean defaultSortable
public Number defaultWidth
public function ColumnModel(Object config
)
config
: Objectpublic function addEvents(Object object
)
object
: Objectvoid
public function addListener(String eventName
, Function handler
, [Object scope
], [Object options
])
eventName
: Stringhandler
: Functionscope
: Objectoptions
: Object
组合选项
使用选项参数可以组合不同类型的监听器:
下面是一个标准的、延迟执行的、一次性的监听器,将会自动停止事件并传递一个自定义的参数(forumId)
el.on('click', this.onClick, this, { single: true, delay: 100, stopEvent : true, forumId: 4 });
这个方法也允许传递的单个参数是一个包含多个指定处理函数的设置对象。
一次调用多个处理函数
代码:
el.on({ 'click' : { fn: this.onClick scope: this, delay: 100 }, 'mouseover' : { fn: this.onMouseOver scope: this }, 'mouseout' : { fn: this.onMouseOut scope: this } });
或者简写为:
代码:
el.on({ 'click' : this.onClick, 'mouseover' : this.onMouseOver, 'mouseout' : this.onMouseOut scope: this });
void
public function fireEvent(String eventName
, Object... args
)
eventName
: Stringargs
: Object...Boolean
public function getCellEditor(Number colIndex
, Number rowIndex
)
colIndex
: NumberrowIndex
: NumberObject
public function getColumnCount()
Number
public function getColumnHeader(Number col
)
col
: NumberString
public function getColumnId(Number index
)
index
: NumberString
public function getColumnTooltip(Number col
)
col
: NumberString
public function getColumnWidth(Number col
)
col
: NumberNumber
public function getDataIndex(Number col
)
col
: NumberNumber
public function getRenderer(Number col
)
col
: NumberFunction
public function getTotalWidth(Boolean includeHidden
)
includeHidden
: BooleanNumber
public function hasListener(String eventName
)
eventName
: StringBoolean
public function isCellEditable(Number colIndex
, Number rowIndex
)
colIndex
: NumberrowIndex
: NumberBoolean
public function isFixed()
void
public function isHidden(Number colIndex
)
colIndex
: NumberBoolean
public function isResizable()
Boolean
public function isSortable(Number col
)
col
: NumberBoolean
public function on(String eventName
, Function handler
, [Object options
])
eventName
: Stringhandler
: Functionoptions
: Objectvoid
public function purgeListeners()
void
public function removeListener(String eventName
, Function handler
, [Object scope
])
eventName
: Stringhandler
: Functionscope
: Objectvoid
public function setColumnHeader(Number col
, String header
)
col
: Numberheader
: Stringvoid
public function setColumnTooltip(Number col
, String tooltip
)
col
: Numbertooltip
: Stringvoid
public function setColumnWidth(Number col
, Number width
)
col
: Numberwidth
: Numbervoid
public function setDataIndex(Number col
, Number dataIndex
)
col
: NumberdataIndex
: Numbervoid
public function setEditable(Number col
, Boolean editable
)
col
: Numbereditable
: Booleanvoid
public function setEditor(Number col
, Object editor
)
col
: Numbereditor
: Objectvoid
public function setHidden(Number colIndex
, Boolean hidden
)
colIndex
: Numberhidden
: Booleanvoid
public function setRenderer(Number col
, Function fn
)
col
: Numberfn
: Functionvoid
public function un(String eventName
, Function handler
, [Object scope
])
eventName
: Stringhandler
: Functionscope
: Objectvoid
public event columlockchange
this
: ColumnModelcolIndex
: Numberlocked
: Booleanpublic event columnmoved
this
: ColumnModeloldIndex
: NumbernewIndex
: Numberpublic event headerchange
this
: ColumnModelcolumnIndex
: NumbernewText
: Numberpublic event hiddenchange
this
: ColumnModelcolumnIndex
: Numberhidden
: Numberpublic event widthchange
this
: ColumnModelcolumnIndex
: NumbernewWidth
: Number