打印版式

Class Ext.grid.Grid

Package:Ext.grid
Class:Grid
Extends:Observable
Subclasses:EditorGrid
Defined In:Grid.js
This class represents the primary interface of a component based grid control.

Usage:
var grid = new Ext.grid.Grid("my-container-id", {
     ds: myDataStore,
     cm: myColModel,
     selModel: mySelectionModel,
     autoSizeColumns: true,
     monitorWindowResize: false,
     trackMouseOver: true
 });
 // set any options
 grid.render();
Common Problems:
- Grid does not resize properly when going smaller: Setting overflow hidden on the container element will correct this
- If you get el.style[camel]= NaNpx or -2px or something related, be certain you have given your container element dimensions. The grid adapts to your container's size, if your container has no size defined then the results are unpredictable.
- Do not render the grid into an element with display:none. Try using visibility:hidden. Otherwise there is no way for the grid to calculate dimensions/offsets.

属性   -  方法   -  事件   -  设置选项

公共属性

属性 定义对象
  ddText : String Grid
Configures the text is the drag proxy (defaults to "%0 selected row(s)"). %0 is replaced with the number of selected ...

公共方法

方法 定义对象
  Grid(String/HTMLElement/Ext.Element container, Object config) Grid
  addEvents(Object object) : void Observable
将对象中没有的事件从给出的对象中复制过来。
  addListener(String eventName, Function handler, [Object scope], [Object options]) : void Observable
为该组件加入事件处理器函数
  autoSize() : void Grid
Causes the grid to manually recalculate its dimensions. Generally this is done automatically, but if manual update is...
  destroy(Boolean removeEl) : void Grid
Destroy this grid.
  fireEvent(String eventName, Object... args) : Boolean Observable
触发指定的事件, 并将参数传入(至少要有事件名称)。
  getColumnModel() : ColumnModel Grid
Returns the grid's ColumnModel.
  getDataSource() : DataSource Grid
Returns the grid's DataSource.
  getDragDropText() : String Grid
Called to get grid's drag proxy text, by default returns this.ddText.
  getSelectionModel() : SelectionModel Grid
Returns the grid's SelectionModel.
  getView() : GridView Grid
Returns the grid's GridView object.
  hasListener(String eventName) : Boolean Observable
检查该对象是否拥有指定事件的侦听器
  on(String eventName, Function handler, [Object options]) : void Observable
为该组件加入事件处理器函数, addListener 的简写方式
  purgeListeners() : void Observable
从对象身上移除所有的侦听器
  removeListener(String eventName, Function handler, [Object scope]) : void Observable
移除侦听器
  render() : Ext.grid.Grid Grid
* Called once after all setup has been completed and the grid is ready to be rendered.
  un(String eventName, Function handler, [Object scope]) : void Observable
移除侦听器, removeListener 的简写方式

公共事件

事件 定义对象
  bodyscroll : (Number scrollLeft, Number scrollTop) Grid
Fires when the body element is scrolled
  cellclick : (Grid this, Number rowIndex, Number columnIndex, Ext.EventObject e) Grid
Fires when a cell is clicked
  cellcontextmenu : (Grid this, Number rowIndex, Number cellIndex, Ext.EventObject e) Grid
Fires when a cell is right clicked
  celldblclick : (Grid this, Number rowIndex, Number columnIndex, Ext.EventObject e) Grid
Fires when a cell is double clicked
  click : (Ext.EventObject e) Grid
The raw click event for the entire grid.
  columnmove : (Number oldIndex, Number newIndex) Grid
Fires when the user moves a column
  columnresize : (Number columnIndex, Number newSize) Grid
Fires when the user resizes a column
  contextmenu : (Ext.EventObject e) Grid
The raw contextmenu event for the entire grid.
  dblclick : (Ext.EventObject e) Grid
The raw dblclick event for the entire grid.
  dragdrop : (Grid this, Ext.GridDD dd, String targetId, event e) Grid
Fires when dragged row(s) are dropped on a valid DD target
  dragenter : (Grid this, Ext.GridDD dd, String targetId, event e) Grid
Fires when the dragged row(s) first cross another DD target while being dragged
  dragout : (Grid this, Ext.GridDD dd, String targetId, event e) Grid
Fires when the dragged row(s) leave another DD target while being dragged
  dragover : (Grid this, Ext.GridDD dd, String targetId, event e) Grid
Fires while row(s) are being dragged. "targetId" is the id of the Yahoo.util.DD object the selected rows are being dr...
  enddrag : (Grid this, Ext.GridDD dd, event e) Grid
Fires when a drag operation is complete
  headerclick : (Grid this, Number columnIndex, Ext.EventObject e) Grid
Fires when a header is clicked
  headercontextmenu : (Grid this, Number columnIndex, Ext.EventObject e) Grid
Fires when a header is right clicked
  headerdblclick : (Grid this, Number rowIndex, Number columnIndex, Ext.EventObject e) Grid
Fires when a header cell is double clicked
  keydown : (Ext.EventObject e) Grid
The raw keydown event for the entire grid.
  keypress : (Ext.EventObject e) Grid
The raw keypress event for the entire grid.
  mousedown : (Ext.EventObject e) Grid
The raw mousedown event for the entire grid.
  mouseout : (Ext.EventObject e) Grid
The raw mouseout event for the entire grid.
  mouseover : (Ext.EventObject e) Grid
The raw mouseover event for the entire grid.
  mouseup : (Ext.EventObject e) Grid
The raw mouseup event for the entire grid.
  rowclick : (Grid this, Number rowIndex, Ext.EventObject e) Grid
Fires when a row is clicked
  rowcontextmenu : (Grid this, Number rowIndex, Ext.EventObject e) Grid
Fires when a row is right clicked
  rowdblclick : (Grid this, Number rowIndex, Ext.EventObject e) Grid
Fires when a row is double clicked
  startdrag : (Grid this, Ext.GridDD dd, event e) Grid
Fires when row(s) start being dragged

设置选项

设置选项 定义对象
  A : Object Grid
javascript RegExp defining tagNames allowed to have text selection (Defaults to /INPUT|TEXTAREA|SELECT/i).
  An : Object Grid
Ext.LoadMask config or true to mask the grid while loading (defaults to false).
  If : Boolean Grid
autoSizeColumns is on, maxRowsToMeasure can be used to limit the number of rows measured to get a columns size - defa...
  The : Object Grid
Ext.grid.GridView used by the grid. This can be set before a call to render().
  True : Boolean Grid
to fit the height of the grid container to the height of the data. Defaults to false.

属性详情

ddText

public String ddText
Configures the text is the drag proxy (defaults to "%0 selected row(s)"). %0 is replaced with the number of selected rows.
This property is defined by Grid.

构造函数

Grid

public function Grid(String/HTMLElement/Ext.Element container, Object config)
参数:
  • container : String/HTMLElement/Ext.Element
    The element into which this grid will be rendered - The container MUST have some type of size defined for the grid to fill. The container will be automatically set to position relative if it isn't already.
  • config : Object
    A config object that sets properties on this grid.

方法详情

addEvents

public function addEvents(Object object)
将对象中没有的事件从给出的对象中复制过来。给出的对象必须也继承于 Observable 对象此方法才会有效果。
参数:
  • object : Object
    要复制事件的源对象
返回:
  • void
This method is defined by Observable.

addListener

public function addListener(String eventName, Function handler, [Object scope], [Object options])
为组件添加一个事件监听器
参数:
  • eventName : String
    侦听事件的类型
  • handler : Function
    事件调用的方法
  • scope : Object
    (可选)处理函数执行的作用域。处理函数 "this" 的内容。
  • options : Object
    (可选)一个包含处理设置属性的对象。可以包含下列的属性:
    • scope {Object} 处理函数执行的作用域。处理函数 "this" 的内容。
    • delegate {String} 一个简单的选择器用来过滤目标或查找目标的子节点。
    • stopEvent {Boolean} 值为 True 时用来中止事件。那样将中止传播,并防止缺省动作。
    • preventDefault {Boolean} 值为 True 时用来防止缺省动作。
    • stopPropagation {Boolean} 值为 True 时用来中止事件传播。
    • normalized {Boolean} 值为 False 时向处理函数传递浏览器事件用以代替 Ext.EventObject 对象。
    • delay {Number} 当事件触发后启用处理函数的延迟微秒数。
    • single {Boolean} 值为 True 时将添加一个处理函数用来处理下个触发的事件,并在处理完后移除。
    • buffer {Number} 使处理函数计划在由 Ext.util.DelayedTask 指定的微秒数后执行。如果事件在延迟期间再次触发,原来的处理函数将不再启动,而是由新的计划代替。

    组合选项
    使用选项参数可以组合不同类型的监听器:

    下面是一个标准的、延迟执行的、一次性的监听器,将会自动停止事件并传递一个自定义的参数(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
This method is defined by Observable.

autoSize

public function autoSize()
Causes the grid to manually recalculate its dimensions. Generally this is done automatically, but if manual update is required this method will initiate it.
参数:
  • 无。
返回:
  • void
This method is defined by Grid.

destroy

public function destroy(Boolean removeEl)
Destroy this grid.
参数:
  • removeEl : Boolean
    True to remove the element
返回:
  • void
This method is defined by Grid.

fireEvent

public function fireEvent(String eventName, Object... args)
触发指定的事件并给出参数(至少要有事件名称)。
参数:
  • eventName : String
  • args : Object...
    传入处理函数的参数
返回:
  • Boolean
    如果任何处理函数返回 false 则返回值为 false, 否则返回 true。
This method is defined by Observable.

getColumnModel

public function getColumnModel()
Returns the grid's ColumnModel.
参数:
  • 无。
返回:
  • ColumnModel
This method is defined by Grid.

getDataSource

public function getDataSource()
Returns the grid's DataSource.
参数:
  • 无。
返回:
  • DataSource
This method is defined by Grid.

getDragDropText

public function getDragDropText()
Called to get grid's drag proxy text, by default returns this.ddText.
参数:
  • 无。
返回:
  • String
This method is defined by Grid.

getSelectionModel

public function getSelectionModel()
Returns the grid's SelectionModel.
参数:
  • 无。
返回:
  • SelectionModel
This method is defined by Grid.

getView

public function getView()
Returns the grid's GridView object.
参数:
  • 无。
返回:
  • GridView
This method is defined by Grid.

hasListener

public function hasListener(String eventName)
检查该对象是否拥有指定事件的侦听器
参数:
  • eventName : String
    查询事件之名称
返回:
  • Boolean
    值为 True 值表示事件监听器存在, 否则值为 false。
This method is defined by Observable.

on

public function on(String eventName, Function handler, [Object options])
为该组件加入事件处理器函数, addListener 的简写方式
参数:
  • eventName : String
    侦听事件的类型
  • handler : Function
    事件调用的方法
  • options : Object
    (可选)
返回:
  • void
This method is defined by Observable.

purgeListeners

public function purgeListeners()
从对象身上移除所有的侦听器
参数:
  • 无。
返回:
  • void
This method is defined by Observable.

removeListener

public function removeListener(String eventName, Function handler, [Object scope])
移除侦听器
参数:
  • eventName : String
    侦听事件的类型
  • handler : Function
    删除的处理函数
  • scope : Object
    (可选) The scope (this object) for the handler
返回:
  • void
This method is defined by Observable.

render

public function render()
* Called once after all setup has been completed and the grid is ready to be rendered.
参数:
  • 无。
返回:
  • Ext.grid.Grid
    this
This method is defined by Grid.

un

public function un(String eventName, Function handler, [Object scope])
移除侦听器, removeListener 的简写方式
参数:
  • eventName : String
    侦听事件的类型
  • handler : Function
    删除的处理函数
  • scope : Object
    (可选) The scope (this object) for the handler
返回:
  • void
This method is defined by Observable.

事件详情

bodyscroll

public event bodyscroll
Fires when the body element is scrolled
Subscribers will be called with the following parameters:
  • scrollLeft : Number
  • scrollTop : Number
This event is defined by Grid.

cellclick

public event cellclick
Fires when a cell is clicked
Subscribers will be called with the following parameters:
  • this : Grid
  • rowIndex : Number
  • columnIndex : Number
  • e : Ext.EventObject
This event is defined by Grid.

cellcontextmenu

public event cellcontextmenu
Fires when a cell is right clicked
Subscribers will be called with the following parameters:
  • this : Grid
  • rowIndex : Number
  • cellIndex : Number
  • e : Ext.EventObject
This event is defined by Grid.

celldblclick

public event celldblclick
Fires when a cell is double clicked
Subscribers will be called with the following parameters:
  • this : Grid
  • rowIndex : Number
  • columnIndex : Number
  • e : Ext.EventObject
This event is defined by Grid.

click

public event click
The raw click event for the entire grid.
Subscribers will be called with the following parameters:
  • e : Ext.EventObject
This event is defined by Grid.

columnmove

public event columnmove
Fires when the user moves a column
Subscribers will be called with the following parameters:
  • oldIndex : Number
  • newIndex : Number
This event is defined by Grid.

columnresize

public event columnresize
Fires when the user resizes a column
Subscribers will be called with the following parameters:
  • columnIndex : Number
  • newSize : Number
This event is defined by Grid.

contextmenu

public event contextmenu
The raw contextmenu event for the entire grid.
Subscribers will be called with the following parameters:
  • e : Ext.EventObject
This event is defined by Grid.

dblclick

public event dblclick
The raw dblclick event for the entire grid.
Subscribers will be called with the following parameters:
  • e : Ext.EventObject
This event is defined by Grid.

dragdrop

public event dragdrop
Fires when dragged row(s) are dropped on a valid DD target
Subscribers will be called with the following parameters:
  • this : Grid
  • dd : Ext.GridDD
    The drag drop object
  • targetId : String
    The target drag drop object
  • e : event
    The raw browser event
This event is defined by Grid.

dragenter

public event dragenter
Fires when the dragged row(s) first cross another DD target while being dragged
Subscribers will be called with the following parameters:
  • this : Grid
  • dd : Ext.GridDD
    The drag drop object
  • targetId : String
    The target drag drop object
  • e : event
    The raw browser event
This event is defined by Grid.

dragout

public event dragout
Fires when the dragged row(s) leave another DD target while being dragged
Subscribers will be called with the following parameters:
  • this : Grid
  • dd : Ext.GridDD
    The drag drop object
  • targetId : String
    The target drag drop object
  • e : event
    The raw browser event
This event is defined by Grid.

dragover

public event dragover
Fires while row(s) are being dragged. "targetId" is the id of the Yahoo.util.DD object the selected rows are being dragged over.
Subscribers will be called with the following parameters:
  • this : Grid
  • dd : Ext.GridDD
    The drag drop object
  • targetId : String
    The target drag drop object
  • e : event
    The raw browser event
This event is defined by Grid.

enddrag

public event enddrag
Fires when a drag operation is complete
Subscribers will be called with the following parameters:
  • this : Grid
  • dd : Ext.GridDD
    The drag drop object
  • e : event
    The raw browser event
This event is defined by Grid.

headerclick

public event headerclick
Fires when a header is clicked
Subscribers will be called with the following parameters:
  • this : Grid
  • columnIndex : Number
  • e : Ext.EventObject
This event is defined by Grid.

headercontextmenu

public event headercontextmenu
Fires when a header is right clicked
Subscribers will be called with the following parameters:
  • this : Grid
  • columnIndex : Number
  • e : Ext.EventObject
This event is defined by Grid.

headerdblclick

public event headerdblclick
Fires when a header cell is double clicked
Subscribers will be called with the following parameters:
  • this : Grid
  • rowIndex : Number
  • columnIndex : Number
  • e : Ext.EventObject
This event is defined by Grid.

keydown

public event keydown
The raw keydown event for the entire grid.
Subscribers will be called with the following parameters:
  • e : Ext.EventObject
This event is defined by Grid.

keypress

public event keypress
The raw keypress event for the entire grid.
Subscribers will be called with the following parameters:
  • e : Ext.EventObject
This event is defined by Grid.

mousedown

public event mousedown
The raw mousedown event for the entire grid.
Subscribers will be called with the following parameters:
  • e : Ext.EventObject
This event is defined by Grid.

mouseout

public event mouseout
The raw mouseout event for the entire grid.
Subscribers will be called with the following parameters:
  • e : Ext.EventObject
This event is defined by Grid.

mouseover

public event mouseover
The raw mouseover event for the entire grid.
Subscribers will be called with the following parameters:
  • e : Ext.EventObject
This event is defined by Grid.

mouseup

public event mouseup
The raw mouseup event for the entire grid.
Subscribers will be called with the following parameters:
  • e : Ext.EventObject
This event is defined by Grid.

rowclick

public event rowclick
Fires when a row is clicked
Subscribers will be called with the following parameters:
  • this : Grid
  • rowIndex : Number
  • e : Ext.EventObject
This event is defined by Grid.

rowcontextmenu

public event rowcontextmenu
Fires when a row is right clicked
Subscribers will be called with the following parameters:
  • this : Grid
  • rowIndex : Number
  • e : Ext.EventObject
This event is defined by Grid.

rowdblclick

public event rowdblclick
Fires when a row is double clicked
Subscribers will be called with the following parameters:
  • this : Grid
  • rowIndex : Number
  • e : Ext.EventObject
This event is defined by Grid.

startdrag

public event startdrag
Fires when row(s) start being dragged
Subscribers will be called with the following parameters:
  • this : Grid
  • dd : Ext.GridDD
    The drag drop object
  • e : event
    The raw browser event
This event is defined by Grid.

设置详情

A

A : Object
javascript RegExp defining tagNames allowed to have text selection (Defaults to /INPUT|TEXTAREA|SELECT/i).
This config option is defined by Grid.

An

An : Object
Ext.LoadMask config or true to mask the grid while loading (defaults to false).
This config option is defined by Grid.

If

If : Boolean
autoSizeColumns is on, maxRowsToMeasure can be used to limit the number of rows measured to get a columns size - defaults to 0 (all rows).
This config option is defined by Grid.

The

The : Object
Ext.grid.GridView used by the grid. This can be set before a call to render().
This config option is defined by Grid.

True

True : Boolean
to fit the height of the grid container to the height of the data. Defaults to false.
This config option is defined by Grid.

Ext - Copyright © 2006-2007 Ext JS, LLC
All rights reserved.