?? gridpanel.js
字號:
/**
* @class Ext.grid.GridPanel
* @extends Ext.Panel
* This class represents the primary interface of a component based grid control.
* <br><br>Usage:
* <pre><code>var grid = new Ext.grid.GridPanel({
store: new Ext.data.Store({
reader: reader,
data: xg.dummyData
}),
columns: [
{id:'company', header: "Company", width: 200, sortable: true, dataIndex: 'company'},
{header: "Price", width: 120, sortable: true, renderer: Ext.util.Format.usMoney, dataIndex: 'price'},
{header: "Change", width: 120, sortable: true, dataIndex: 'change'},
{header: "% Change", width: 120, sortable: true, dataIndex: 'pctChange'},
{header: "Last Updated", width: 135, sortable: true, renderer: Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'lastChange'}
],
viewConfig: {
forceFit: true
},
sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
width:600,
height:300,
frame:true,
title:'Framed with Checkbox Selection and Horizontal Scrolling',
iconCls:'icon-grid'
});</code></pre>
* <b>Note:</b> Although this class inherits many configuration options from base classes, some of them
* (such as autoScroll, layout, items, etc) won't function as they do with the base Panel class.
*/
Ext.grid.GridPanel = Ext.extend(Ext.Panel, {
elements:'body',
/**
* @cfg {Array} columns An array of columns to auto create a ColumnModel
*/
/**
* @cfg {Ext.data.Store} store The Ext.data.Store the grid should use as it's data source (required).
*/
/**
* @cfg {Object} cm Shorthand for {@link #colModel}.
*/
/**
* @cfg {Object} colModel The {@link Ext.grid.ColumnModel} to use when rendering the grid (required).
*/
/**
* @cfg {Object} sm Shorthand for {@link #selModel}.
*/
/**
* @cfg {Object} selModel Any subclass of AbstractSelectionModel that will provide the selection model for
* the grid (defaults to {@link Ext.grid.RowSelectionModel} if not specified).
*/
/**
* @cfg {Array} columns An array of columns to auto create a ColumnModel
*/
/**
* @cfg {Number} maxHeight Sets the maximum height of the grid - ignored if autoHeight is not on.
*/
/**
* @cfg {Boolean} disableSelection True to disable selections in the grid (defaults to false).
*/
/**
* @cfg {Boolean} enableColumnMove False to turn off column reordering via drag drop (defaults to true).
*/
/**
* @cfg {Boolean} enableColumnResize False to turn off column resizing for the whole grid (defaults to true).
*/
/**
* @cfg {Object} viewConfig A config object that will be applied to the grid's UI view. Any of
* the config options available for {@link Ext.grid.GridView} can be specified here.
*/
/**
* Configures the text in the drag proxy (defaults to "{0} selected row(s)").
* {0} is replaced with the number of selected rows.
* @type String
*/
ddText : "{0} selected row{1}",
/**
* @cfg {Number} minColumnWidth The minimum width a column can be resized to. Defaults to 25.
*/
minColumnWidth : 25,
/**
* @cfg {Boolean} monitorWindowResize True to autoSize the grid when the window resizes. Defaults to true.
*/
monitorWindowResize : true,
/**
* @cfg {Boolean} maxRowsToMeasure If autoSizeColumns is on, maxRowsToMeasure can be used to limit the number of
* rows measured to get a columns size - defaults to 0 (all rows).
*/
maxRowsToMeasure : 0,
/**
* @cfg {Boolean} trackMouseOver True to highlight rows when the mouse is over. Default is false.
*/
trackMouseOver : true,
/**
* @cfg {Boolean} enableDragDrop True to enable drag and drop of rows.
*/
enableDragDrop : false,
/**
* @cfg {Boolean} enableColumnMove True to enable drag and drop reorder of columns.
*/
enableColumnMove : true,
/**
* @cfg {Boolean} enableColumnHide True to enable hiding of columns with the header context menu.
*/
enableColumnHide : true,
/**
* @cfg {Boolean} enableHdMenu True to enable the drop down button for menu in the headers.
*/
enableHdMenu : true,
/**
* @cfg {Boolean} enableRowHeightSync True to manually sync row heights across locked and not locked rows.
*/
enableRowHeightSync : false,
/**
* @cfg {Boolean} stripeRows True to stripe the rows. Default is true.
*/
stripeRows : true,
/**
* @cfg {String} autoExpandColumn The id of a column in this grid that should expand to fill unused space. This id can not be 0.
*/
autoExpandColumn : false,
/**
* @cfg {Number} autoExpandMin The minimum width the autoExpandColumn can have (if enabled).
* defaults to 50.
*/
autoExpandMin : 50,
/**
* @cfg {Number} autoExpandMax The maximum width the autoExpandColumn can have (if enabled). Defaults to 1000.
*/
autoExpandMax : 1000,
/**
* @cfg {Object} view The {@link Ext.grid.GridView} used by the grid. This can be set before a call to render().
*/
view : null,
/**
* @cfg {Object} loadMask An {@link Ext.LoadMask} config or true to mask the grid while loading (defaults to false).
*/
loadMask : false,
// private
rendered : false,
// private
viewReady: false,
// private
stateEvents: ["columnmove", "columnresize", "sortchange"],
// private
initComponent : function(){
Ext.grid.GridPanel.superclass.initComponent.call(this);
if(this.columns && (this.columns instanceof Array)){
this.colModel = new Ext.grid.ColumnModel(this.columns);
delete this.columns;
}
// check and correct shorthanded configs
if(this.ds){
this.store = this.ds;
delete this.ds;
}
if(this.cm){
this.colModel = this.cm;
delete this.cm;
}
if(this.sm){
this.selModel = this.sm;
delete this.sm;
}
this.store = Ext.StoreMgr.lookup(this.store);
this.addEvents({
// raw events
/**
* @event click
* The raw click event for the entire grid.
* @param {Ext.EventObject} e
*/
"click" : true,
/**
* @event dblclick
* The raw dblclick event for the entire grid.
* @param {Ext.EventObject} e
*/
"dblclick" : true,
/**
* @event contextmenu
* The raw contextmenu event for the entire grid.
* @param {Ext.EventObject} e
*/
"contextmenu" : true,
/**
* @event mousedown
* The raw mousedown event for the entire grid.
* @param {Ext.EventObject} e
*/
"mousedown" : true,
/**
* @event mouseup
* The raw mouseup event for the entire grid.
* @param {Ext.EventObject} e
*/
"mouseup" : true,
/**
* @event mouseover
* The raw mouseover event for the entire grid.
* @param {Ext.EventObject} e
*/
"mouseover" : true,
/**
* @event mouseout
* The raw mouseout event for the entire grid.
* @param {Ext.EventObject} e
*/
"mouseout" : true,
/**
* @event keypress
* The raw keypress event for the entire grid.
* @param {Ext.EventObject} e
*/
"keypress" : true,
/**
* @event keydown
* The raw keydown event for the entire grid.
* @param {Ext.EventObject} e
*/
"keydown" : true,
// custom events
/**
* @event cellmousedown
* Fires before a cell is clicked
* @param {Grid} this
* @param {Number} rowIndex
* @param {Number} columnIndex
* @param {Ext.EventObject} e
*/
"cellmousedown" : true,
/**
* @event rowmousedown
* Fires before a row is clicked
* @param {Grid} this
* @param {Number} rowIndex
* @param {Ext.EventObject} e
*/
"rowmousedown" : true,
/**
* @event headermousedown
* Fires before a header is clicked
* @param {Grid} this
* @param {Number} columnIndex
* @param {Ext.EventObject} e
*/
"headermousedown" : true,
/**
* @event cellclick
* Fires when a cell is clicked
* @param {Grid} this
* @param {Number} rowIndex
* @param {Number} columnIndex
* @param {Ext.EventObject} e
*/
"cellclick" : true,
/**
* @event celldblclick
* Fires when a cell is double clicked
* @param {Grid} this
* @param {Number} rowIndex
* @param {Number} columnIndex
* @param {Ext.EventObject} e
*/
"celldblclick" : true,
/**
* @event rowclick
* Fires when a row is clicked
* @param {Grid} this
* @param {Number} rowIndex
* @param {Ext.EventObject} e
*/
"rowclick" : true,
/**
* @event rowdblclick
* Fires when a row is double clicked
* @param {Grid} this
* @param {Number} rowIndex
* @param {Ext.EventObject} e
*/
"rowdblclick" : true,
/**
* @event headerclick
* Fires when a header is clicked
* @param {Grid} this
* @param {Number} columnIndex
* @param {Ext.EventObject} e
*/
"headerclick" : true,
/**
* @event headerdblclick
* Fires when a header cell is double clicked
* @param {Grid} this
* @param {Number} columnIndex
* @param {Ext.EventObject} e
*/
"headerdblclick" : true,
/**
* @event rowcontextmenu
* Fires when a row is right clicked
* @param {Grid} this
* @param {Number} rowIndex
* @param {Ext.EventObject} e
*/
"rowcontextmenu" : true,
/**
* @event cellcontextmenu
* Fires when a cell is right clicked
* @param {Grid} this
* @param {Number} rowIndex
* @param {Number} cellIndex
* @param {Ext.EventObject} e
*/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -