X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/0494b8d9b9bb03ab6c22b34dae81261e3cd7e3e6..7a654f8d43fdb43d78b63d90528bed6e86b608cc:/src/grid/column/Action.js diff --git a/src/grid/column/Action.js b/src/grid/column/Action.js new file mode 100644 index 00000000..540920cd --- /dev/null +++ b/src/grid/column/Action.js @@ -0,0 +1,214 @@ +/** + * @class Ext.grid.column.Action + * @extends Ext.grid.column.Column + *
A Grid header type which renders an icon, or a series of icons in a grid cell, and offers a scoped click + * handler for each icon.
+ * + * {@img Ext.grid.column.Action/Ext.grid.column.Action.png Ext.grid.column.Action grid column} + * + * ## Code + * Ext.create('Ext.data.Store', { + * storeId:'employeeStore', + * fields:['firstname', 'lastname', 'senority', 'dep', 'hired'], + * data:[ + * {firstname:"Michael", lastname:"Scott"}, + * {firstname:"Dwight", lastname:"Schrute"}, + * {firstname:"Jim", lastname:"Halpert"}, + * {firstname:"Kevin", lastname:"Malone"}, + * {firstname:"Angela", lastname:"Martin"} + * ] + * }); + * + * Ext.create('Ext.grid.Panel', { + * title: 'Action Column Demo', + * store: Ext.data.StoreManager.lookup('employeeStore'), + * columns: [ + * {text: 'First Name', dataIndex:'firstname'}, + * {text: 'Last Name', dataIndex:'lastname'}, + * { + * xtype:'actioncolumn', + * width:50, + * items: [{ + * icon: 'images/edit.png', // Use a URL in the icon config + * tooltip: 'Edit', + * handler: function(grid, rowIndex, colIndex) { + * var rec = grid.getStore().getAt(rowIndex); + * alert("Edit " + rec.get('firstname')); + * } + * },{ + * icon: 'images/delete.png', + * tooltip: 'Delete', + * handler: function(grid, rowIndex, colIndex) { + * var rec = grid.getStore().getAt(rowIndex); + * alert("Terminate " + rec.get('firstname')); + * } + * }] + * } + * ], + * width: 250, + * renderTo: Ext.getBody() + * }); + *The action column can be at any index in the columns array, and a grid can have any number of + * action columns.
+ * @xtype actioncolumn + */ +Ext.define('Ext.grid.column.Action', { + extend: 'Ext.grid.column.Column', + alias: ['widget.actioncolumn'], + alternateClassName: 'Ext.grid.ActionColumn', + + /** + * @cfg {String} icon + * The URL of an image to display as the clickable element in the column. + * Optional - defaults to{@link Ext#BLANK_IMAGE_URL Ext.BLANK_IMAGE_URL}
.
+ */
+ /**
+ * @cfg {String} iconCls
+ * A CSS class to apply to the icon image. To determine the class dynamically, configure the Column with a {@link #getClass}
function.
+ */
+ /**
+ * @cfg {Function} handler A function called when the icon is clicked.
+ * The handler is passed the following parameters:view
: TableViewrowIndex
: NumbercolIndex
: Numberitem
: Objecte
: Event{@link #handler}
+ * and {@link #getClass}
fuctions are executed. Defaults to this Column.
+ */
+ /**
+ * @cfg {String} tooltip A tooltip message to be displayed on hover. {@link Ext.tip.QuickTipManager#init Ext.tip.QuickTipManager} must have
+ * been initialized.
+ */
+ /**
+ * @cfg {Boolean} stopSelection Defaults to true
. Prevent grid row selection upon mousedown.
+ */
+ /**
+ * @cfg {Function} getClass A function which returns the CSS class to apply to the icon image.
+ * The function is passed the following parameters:The value of the column's configured field (if any).
An object in which you may set the following attributes:
A CSS class name to add to the cell's TD element.
An HTML attribute definition string to apply to the data container element within the table cell + * (e.g. 'style="color:red;"').
The Record providing the data.
The row index..
The column index.
The Store which is providing the data Model.
icon
: StringiconCls
: StringgetClass
function.getClass
: FunctionThe value of the column's configured field (if any).
An object in which you may set the following attributes:
A CSS class name to add to the cell's TD element.
An HTML attribute definition string to apply to the data container element within the table cell + * (e.g. 'style="color:red;"').
The Record providing the data.
The row index..
The column index.
The Store which is providing the data Model.
handler
: Functionscope
: Scopethis
reference) in which the
+ * handler
and getClass
functions are executed. Fallback defaults are this Column's
+ * configured scope, then this Column.tooltip
: String