1 if(!dojo._hasResource["dojox.grid._grid.publicEvents"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2 dojo._hasResource["dojox.grid._grid.publicEvents"] = true;
3 dojo.provide("dojox.grid._grid.publicEvents");
5 dojox.grid.publicEvents = {
7 // VirtualGrid mixin that provides default implementations for grid events.
9 // Default ynthetic events dispatched for VirtualGrid. dojo.connect to events to
10 // retain default implementation or override them for custom handling.
12 // cellOverClass: String
13 // css class to apply to grid cells over which the cursor is placed.
14 cellOverClass: "dojoxGrid-cell-over",
16 onKeyEvent: function(e){
17 // summary: top level handler for Key Events
18 this.dispatchKeyEvent(e);
21 onContentEvent: function(e){
22 // summary: Top level handler for Content events
23 this.dispatchContentEvent(e);
26 onHeaderEvent: function(e){
27 // summary: Top level handler for header events
28 this.dispatchHeaderEvent(e);
31 onStyleRow: function(inRow){
33 // Perform row styling on a given row. Called whenever row styling is updated.
36 // Object containing row state information: selected, true if the row is selcted; over:
37 // true of the mouse is over the row; odd: true if the row is odd. Use customClasses and
38 // customStyles to control row css classes and styles; both properties are strings.
40 // example: onStyleRow({ selected: true, over:true, odd:false })
42 customClasses += (odd?" dojoxGrid-row-odd":"") + (selected?" dojoxGrid-row-selected":"") + (over?" dojoxGrid-row-over":"");
44 this.focus.styleRow(inRow);
45 this.edit.styleRow(inRow);
48 onKeyDown: function(e){
50 // Grid key event handler. By default enter begins editing and applies edits, escape cancels and edit,
51 // tab, shift-tab, and arrow keys move grid cell focus.
52 if(e.altKey || e.ctrlKey || e.metaKey){
62 var isEditing = this.edit.isEditing();
65 this.edit.setEditCell(this.focus.cell, this.focus.rowIndex);
70 this.focus[e.shiftKey ? 'previousKey' : 'nextKey'](e);
74 if(!this.edit.isEditing()){
76 var offset = (e.keyCode == dk.LEFT_ARROW) ? 1 : -1;
77 if(dojo._isBodyLtr()){ offset *= -1; }
78 this.focus.move(0, offset);
82 if(!this.edit.isEditing() && this.focus.rowIndex != 0){
84 this.focus.move(-1, 0);
88 if(!this.edit.isEditing() && this.focus.rowIndex+1 != this.model.count){
90 this.focus.move(1, 0);
94 if(!this.edit.isEditing() && this.focus.rowIndex != 0){
96 if(this.focus.rowIndex != this.scroller.firstVisibleRow+1){
97 this.focus.move(this.scroller.firstVisibleRow-this.focus.rowIndex, 0);
99 this.setScrollTop(this.scroller.findScrollTop(this.focus.rowIndex-1));
100 this.focus.move(this.scroller.firstVisibleRow-this.scroller.lastVisibleRow+1, 0);
105 if(!this.edit.isEditing() && this.focus.rowIndex+1 != this.model.count){
107 if(this.focus.rowIndex != this.scroller.lastVisibleRow-1){
108 this.focus.move(this.scroller.lastVisibleRow-this.focus.rowIndex-1, 0);
110 this.setScrollTop(this.scroller.findScrollTop(this.focus.rowIndex+1));
111 this.focus.move(this.scroller.lastVisibleRow-this.scroller.firstVisibleRow-1, 0);
118 onMouseOver: function(e){
120 // Event fired when mouse is over the grid.
122 // Decorated event object contains reference to grid, cell, and rowIndex
123 e.rowIndex == -1 ? this.onHeaderCellMouseOver(e) : this.onCellMouseOver(e);
126 onMouseOut: function(e){
128 // Event fired when mouse moves out of the grid.
130 // Decorated event object that contains reference to grid, cell, and rowIndex
131 e.rowIndex == -1 ? this.onHeaderCellMouseOut(e) : this.onCellMouseOut(e);
134 onMouseDown: function(e){
136 // Event fired when mouse is down inside grid.
138 // Decorated event object that contains reference to grid, cell, and rowIndex
139 e.rowIndex == -1 ? this.onHeaderCellMouseDown(e) : this.onCellMouseDown(e);
142 onMouseOverRow: function(e){
144 // Event fired when mouse is over any row (data or header).
146 // Decorated event object contains reference to grid, cell, and rowIndex
147 if(!this.rows.isOver(e.rowIndex)){
148 this.rows.setOverRow(e.rowIndex);
149 e.rowIndex == -1 ? this.onHeaderMouseOver(e) : this.onRowMouseOver(e);
152 onMouseOutRow: function(e){
154 // Event fired when mouse moves out of any row (data or header).
156 // Decorated event object contains reference to grid, cell, and rowIndex
157 if(this.rows.isOver(-1)){
158 this.onHeaderMouseOut(e);
159 }else if(!this.rows.isOver(-2)){
160 this.rows.setOverRow(-2);
161 this.onRowMouseOut(e);
165 onMouseDownRow: function(e){
167 // Event fired when mouse is down inside grid row
169 // Decorated event object that contains reference to grid, cell, and rowIndex
171 this.onRowMouseDown(e);
175 onCellMouseOver: function(e){
177 // Event fired when mouse is over a cell.
179 // Decorated event object contains reference to grid, cell, and rowIndex
180 dojo.addClass(e.cellNode, this.cellOverClass);
183 onCellMouseOut: function(e){
185 // Event fired when mouse moves out of a cell.
187 // Decorated event object which contains reference to grid, cell, and rowIndex
188 dojo.removeClass(e.cellNode, this.cellOverClass);
191 onCellMouseDown: function(e){
193 // Event fired when mouse is down in a header cell.
195 // Decorated event object which contains reference to grid, cell, and rowIndex
198 onCellClick: function(e){
200 // Event fired when a cell is clicked.
202 // Decorated event object which contains reference to grid, cell, and rowIndex
203 this._click[0] = this._click[1];
205 if(!this.edit.isEditCell(e.rowIndex, e.cellIndex)){
206 this.focus.setFocusCell(e.cell, e.rowIndex);
211 onCellDblClick: function(e){
213 // Event fired when a cell is double-clicked.
215 // Decorated event object contains reference to grid, cell, and rowIndex
217 this.edit.setEditCell(this._click[1].cell, this._click[1].rowIndex);
218 }else if(this._click[0].rowIndex != this._click[1].rowIndex){
219 this.edit.setEditCell(this._click[0].cell, this._click[0].rowIndex);
221 this.edit.setEditCell(e.cell, e.rowIndex);
223 this.onRowDblClick(e);
226 onCellContextMenu: function(e){
228 // Event fired when a cell context menu is accessed via mouse right click.
230 // Decorated event object which contains reference to grid, cell, and rowIndex
231 this.onRowContextMenu(e);
234 onCellFocus: function(inCell, inRowIndex){
236 // Event fired when a cell receives focus.
238 // Cell object containing properties of the grid column.
239 // inRowIndex: Integer
240 // Index of the grid row
241 this.edit.cellFocus(inCell, inRowIndex);
245 onRowClick: function(e){
247 // Event fired when a row is clicked.
249 // Decorated event object which contains reference to grid, cell, and rowIndex
250 this.edit.rowClick(e);
251 this.selection.clickSelectEvent(e);
254 onRowDblClick: function(e){
256 // Event fired when a row is double clicked.
258 // decorated event object which contains reference to grid, cell, and rowIndex
261 onRowMouseOver: function(e){
263 // Event fired when mouse moves over a data row.
265 // Decorated event object which contains reference to grid, cell, and rowIndex
268 onRowMouseOut: function(e){
270 // Event fired when mouse moves out of a data row.
272 // Decorated event object contains reference to grid, cell, and rowIndex
275 onRowMouseDown: function(e){
277 // Event fired when mouse is down in a row.
279 // Decorated event object which contains reference to grid, cell, and rowIndex
282 onRowContextMenu: function(e){
284 // Event fired when a row context menu is accessed via mouse right click.
286 // Decorated event object which contains reference to grid, cell, and rowIndex
291 onHeaderMouseOver: function(e){
293 // Event fired when mouse moves over the grid header.
295 // Decorated event object contains reference to grid, cell, and rowIndex
298 onHeaderMouseOut: function(e){
300 // Event fired when mouse moves out of the grid header.
302 // Decorated event object which contains reference to grid, cell, and rowIndex
305 onHeaderCellMouseOver: function(e){
307 // Event fired when mouse moves over a header cell.
309 // Decorated event object which contains reference to grid, cell, and rowIndex
310 dojo.addClass(e.cellNode, this.cellOverClass);
313 onHeaderCellMouseOut: function(e){
315 // Event fired when mouse moves out of a header cell.
317 // Decorated event object which contains reference to grid, cell, and rowIndex
318 dojo.removeClass(e.cellNode, this.cellOverClass);
321 onHeaderCellMouseDown: function(e) {
323 // Event fired when mouse is down in a header cell.
325 // Decorated event object which contains reference to grid, cell, and rowIndex
328 onHeaderClick: function(e){
330 // Event fired when the grid header is clicked.
332 // Decorated event object which contains reference to grid, cell, and rowIndex
335 onHeaderCellClick: function(e){
337 // Event fired when a header cell is clicked.
339 // Decorated event object which contains reference to grid, cell, and rowIndex
340 this.setSortIndex(e.cell.index);
341 this.onHeaderClick(e);
344 onHeaderDblClick: function(e){
346 // Event fired when the grid header is double clicked.
348 // Decorated event object which contains reference to grid, cell, and rowIndex
351 onHeaderCellDblClick: function(e){
353 // Event fired when a header cell is double clicked.
355 // Decorated event object which contains reference to grid, cell, and rowIndex
356 this.onHeaderDblClick(e);
359 onHeaderCellContextMenu: function(e){
361 // Event fired when a header cell context menu is accessed via mouse right click.
363 // Decorated event object which contains reference to grid, cell, and rowIndex
364 this.onHeaderContextMenu(e);
367 onHeaderContextMenu: function(e){
369 // Event fired when the grid header context menu is accessed via mouse right click.
371 // Decorated event object which contains reference to grid, cell, and rowIndex
376 onStartEdit: function(inCell, inRowIndex){
378 // Event fired when editing is started for a given grid cell
380 // Cell object containing properties of the grid column.
381 // inRowIndex: Integer
382 // Index of the grid row
385 onApplyCellEdit: function(inValue, inRowIndex, inFieldIndex){
387 // Event fired when editing is applied for a given grid cell
389 // Value from cell editor
390 // inRowIndex: Integer
391 // Index of the grid row
392 // inFieldIndex: Integer
393 // Index in the grid's data model
396 onCancelEdit: function(inRowIndex){
398 // Event fired when editing is cancelled for a given grid cell
399 // inRowIndex: Integer
400 // Index of the grid row
403 onApplyEdit: function(inRowIndex){
405 // Event fired when editing is applied for a given grid row
406 // inRowIndex: Integer
407 // Index of the grid row
410 onCanSelect: function(inRowIndex){
412 // Event to determine if a grid row may be selected
413 // inRowIndex: Integer
414 // Index of the grid row
416 // true if the row can be selected
420 onCanDeselect: function(inRowIndex){
422 // Event to determine if a grid row may be deselected
423 // inRowIndex: Integer
424 // Index of the grid row
426 // true if the row can be deselected
430 onSelected: function(inRowIndex){
432 // Event fired when a grid row is selected
433 // inRowIndex: Integer
434 // Index of the grid row
435 this.updateRowStyles(inRowIndex);
438 onDeselected: function(inRowIndex){
440 // Event fired when a grid row is deselected
441 // inRowIndex: Integer
442 // Index of the grid row
443 this.updateRowStyles(inRowIndex);
446 onSelectionChanged: function(){