2150 |
mathias |
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");
|
|
|
4 |
|
|
|
5 |
dojox.grid.publicEvents = {
|
|
|
6 |
// summary:
|
|
|
7 |
// VirtualGrid mixin that provides default implementations for grid events.
|
|
|
8 |
// dojo.connect to events to retain default implementation or override them for custom handling.
|
|
|
9 |
|
|
|
10 |
//cellOverClass: string
|
|
|
11 |
// css class to apply to grid cells over which the cursor is placed.
|
|
|
12 |
cellOverClass: "dojoxGrid-cell-over",
|
|
|
13 |
// top level handlers (more specified handlers below)
|
|
|
14 |
onKeyEvent: function(e){
|
|
|
15 |
this.dispatchKeyEvent(e);
|
|
|
16 |
},
|
|
|
17 |
onContentEvent: function(e){
|
|
|
18 |
this.dispatchContentEvent(e);
|
|
|
19 |
},
|
|
|
20 |
onHeaderEvent: function(e){
|
|
|
21 |
this.dispatchHeaderEvent(e);
|
|
|
22 |
},
|
|
|
23 |
onStyleRow: function(inRow){
|
|
|
24 |
// summary:
|
|
|
25 |
// Perform row styling on a given row. Called whenever row styling is updated.
|
|
|
26 |
// inRow: object
|
|
|
27 |
// Object containing row state information: selected, true if the row is selcted; over:
|
|
|
28 |
// true of the mouse is over the row; odd: true if the row is odd. Use customClasses and
|
|
|
29 |
// customStyles to control row css classes and styles; both properties are strings.
|
|
|
30 |
with(inRow){
|
|
|
31 |
customClasses += (odd?" dojoxGrid-row-odd":"") + (selected?" dojoxGrid-row-selected":"") + (over?" dojoxGrid-row-over":"");
|
|
|
32 |
}
|
|
|
33 |
this.focus.styleRow(inRow);
|
|
|
34 |
this.edit.styleRow(inRow);
|
|
|
35 |
},
|
|
|
36 |
onKeyDown: function(e){
|
|
|
37 |
// summary:
|
|
|
38 |
// grid key event handler. By default enter begins editing and applies edits, escape cancels and edit,
|
|
|
39 |
// tab, shift-tab, and arrow keys move grid cell focus.
|
|
|
40 |
if(e.altKey || e.ctrlKey || e.metaKey ){
|
|
|
41 |
return;
|
|
|
42 |
}
|
|
|
43 |
switch(e.keyCode){
|
|
|
44 |
case dojo.keys.ESCAPE:
|
|
|
45 |
this.edit.cancel();
|
|
|
46 |
break;
|
|
|
47 |
case dojo.keys.ENTER:
|
|
|
48 |
if (!e.shiftKey) {
|
|
|
49 |
var isEditing = this.edit.isEditing();
|
|
|
50 |
this.edit.apply();
|
|
|
51 |
if(!isEditing){
|
|
|
52 |
this.edit.setEditCell(this.focus.cell, this.focus.rowIndex);
|
|
|
53 |
}
|
|
|
54 |
}
|
|
|
55 |
break;
|
|
|
56 |
case dojo.keys.TAB:
|
|
|
57 |
this.focus[e.shiftKey ? 'previousKey' : 'nextKey'](e);
|
|
|
58 |
break;
|
|
|
59 |
case dojo.keys.LEFT_ARROW:
|
|
|
60 |
if(!this.edit.isEditing()){
|
|
|
61 |
this.focus.move(0, -1);
|
|
|
62 |
}
|
|
|
63 |
break;
|
|
|
64 |
case dojo.keys.RIGHT_ARROW:
|
|
|
65 |
if(!this.edit.isEditing()){
|
|
|
66 |
this.focus.move(0, 1);
|
|
|
67 |
}
|
|
|
68 |
break;
|
|
|
69 |
case dojo.keys.UP_ARROW:
|
|
|
70 |
if(!this.edit.isEditing()){
|
|
|
71 |
this.focus.move(-1, 0);
|
|
|
72 |
}
|
|
|
73 |
break;
|
|
|
74 |
case dojo.keys.DOWN_ARROW:
|
|
|
75 |
if(!this.edit.isEditing()){
|
|
|
76 |
this.focus.move(1, 0);
|
|
|
77 |
}
|
|
|
78 |
break;
|
|
|
79 |
}
|
|
|
80 |
},
|
|
|
81 |
onMouseOver: function(e){
|
|
|
82 |
// summary:
|
|
|
83 |
// event fired when mouse is over the grid.
|
|
|
84 |
// e: decorated event object
|
|
|
85 |
// contains reference to grid, cell, and rowIndex
|
|
|
86 |
e.rowIndex == -1 ? this.onHeaderCellMouseOver(e) : this.onCellMouseOver(e);
|
|
|
87 |
},
|
|
|
88 |
onMouseOut: function(e){
|
|
|
89 |
// summary:
|
|
|
90 |
// event fired when mouse moves out of the grid.
|
|
|
91 |
// e: decorated event object
|
|
|
92 |
// contains reference to grid, cell, and rowIndex
|
|
|
93 |
e.rowIndex == -1 ? this.onHeaderCellMouseOut(e) : this.onCellMouseOut(e);
|
|
|
94 |
},
|
|
|
95 |
onMouseOverRow: function(e){
|
|
|
96 |
// summary:
|
|
|
97 |
// event fired when mouse is over any row (data or header).
|
|
|
98 |
// e: decorated event object
|
|
|
99 |
// contains reference to grid, cell, and rowIndex
|
|
|
100 |
if(!this.rows.isOver(e.rowIndex)){
|
|
|
101 |
this.rows.setOverRow(e.rowIndex);
|
|
|
102 |
e.rowIndex == -1 ? this.onHeaderMouseOver(e) : this.onRowMouseOver(e);
|
|
|
103 |
}
|
|
|
104 |
},
|
|
|
105 |
onMouseOutRow: function(e){
|
|
|
106 |
// summary:
|
|
|
107 |
// event fired when mouse moves out of any row (data or header).
|
|
|
108 |
// e: decorated event object
|
|
|
109 |
// contains reference to grid, cell, and rowIndex
|
|
|
110 |
if(this.rows.isOver(-1)){
|
|
|
111 |
this.onHeaderMouseOut(e);
|
|
|
112 |
}else if(!this.rows.isOver(-2)){
|
|
|
113 |
this.rows.setOverRow(-2);
|
|
|
114 |
this.onRowMouseOut(e);
|
|
|
115 |
}
|
|
|
116 |
},
|
|
|
117 |
// cell events
|
|
|
118 |
onCellMouseOver: function(e){
|
|
|
119 |
// summary:
|
|
|
120 |
// event fired when mouse is over a cell.
|
|
|
121 |
// e: decorated event object
|
|
|
122 |
// contains reference to grid, cell, and rowIndex
|
|
|
123 |
dojo.addClass(e.cellNode, this.cellOverClass);
|
|
|
124 |
},
|
|
|
125 |
onCellMouseOut: function(e){
|
|
|
126 |
// summary:
|
|
|
127 |
// event fired when mouse moves out of a cell.
|
|
|
128 |
// e: decorated event object
|
|
|
129 |
// contains reference to grid, cell, and rowIndex
|
|
|
130 |
dojo.removeClass(e.cellNode, this.cellOverClass);
|
|
|
131 |
},
|
|
|
132 |
onCellClick: function(e){
|
|
|
133 |
// summary:
|
|
|
134 |
// event fired when a cell is clicked.
|
|
|
135 |
// e: decorated event object
|
|
|
136 |
// contains reference to grid, cell, and rowIndex
|
|
|
137 |
this.focus.setFocusCell(e.cell, e.rowIndex);
|
|
|
138 |
this.onRowClick(e);
|
|
|
139 |
},
|
|
|
140 |
onCellDblClick: function(e){
|
|
|
141 |
// summary:
|
|
|
142 |
// event fired when a cell is double-clicked.
|
|
|
143 |
// e: decorated event object
|
|
|
144 |
// contains reference to grid, cell, and rowIndex
|
|
|
145 |
this.edit.setEditCell(e.cell, e.rowIndex);
|
|
|
146 |
this.onRowDblClick(e);
|
|
|
147 |
},
|
|
|
148 |
onCellContextMenu: function(e){
|
|
|
149 |
// summary:
|
|
|
150 |
// event fired when a cell context menu is accessed via mouse right click.
|
|
|
151 |
// e: decorated event object
|
|
|
152 |
// contains reference to grid, cell, and rowIndex
|
|
|
153 |
this.onRowContextMenu(e);
|
|
|
154 |
},
|
|
|
155 |
onCellFocus: function(inCell, inRowIndex){
|
|
|
156 |
// summary:
|
|
|
157 |
// event fired when a cell receives focus.
|
|
|
158 |
// inCell: object
|
|
|
159 |
// cell object containing properties of the grid column.
|
|
|
160 |
// inRowIndex: int
|
|
|
161 |
// index of the grid row
|
|
|
162 |
this.edit.cellFocus(inCell, inRowIndex);
|
|
|
163 |
},
|
|
|
164 |
// row events
|
|
|
165 |
onRowClick: function(e){
|
|
|
166 |
// summary:
|
|
|
167 |
// event fired when a row is clicked.
|
|
|
168 |
// e: decorated event object
|
|
|
169 |
// contains reference to grid, cell, and rowIndex
|
|
|
170 |
this.edit.rowClick(e);
|
|
|
171 |
this.selection.clickSelectEvent(e);
|
|
|
172 |
},
|
|
|
173 |
onRowDblClick: function(e){
|
|
|
174 |
// summary:
|
|
|
175 |
// event fired when a row is double clicked.
|
|
|
176 |
// e: decorated event object
|
|
|
177 |
// contains reference to grid, cell, and rowIndex
|
|
|
178 |
},
|
|
|
179 |
onRowMouseOver: function(e){
|
|
|
180 |
// summary:
|
|
|
181 |
// event fired when mouse moves over a data row.
|
|
|
182 |
// e: decorated event object
|
|
|
183 |
// contains reference to grid, cell, and rowIndex
|
|
|
184 |
},
|
|
|
185 |
onRowMouseOut: function(e){
|
|
|
186 |
// summary:
|
|
|
187 |
// event fired when mouse moves out of a data row.
|
|
|
188 |
// e: decorated event object
|
|
|
189 |
// contains reference to grid, cell, and rowIndex
|
|
|
190 |
},
|
|
|
191 |
onRowContextMenu: function(e){
|
|
|
192 |
// summary:
|
|
|
193 |
// event fired when a row context menu is accessed via mouse right click.
|
|
|
194 |
// e: decorated event object
|
|
|
195 |
// contains reference to grid, cell, and rowIndex
|
|
|
196 |
dojo.stopEvent(e);
|
|
|
197 |
},
|
|
|
198 |
// header events
|
|
|
199 |
onHeaderMouseOver: function(e){
|
|
|
200 |
// summary:
|
|
|
201 |
// event fired when mouse moves over the grid header.
|
|
|
202 |
// e: decorated event object
|
|
|
203 |
// contains reference to grid, cell, and rowIndex
|
|
|
204 |
},
|
|
|
205 |
onHeaderMouseOut: function(e){
|
|
|
206 |
// summary:
|
|
|
207 |
// event fired when mouse moves out of the grid header.
|
|
|
208 |
// e: decorated event object
|
|
|
209 |
// contains reference to grid, cell, and rowIndex
|
|
|
210 |
},
|
|
|
211 |
onHeaderCellMouseOver: function(e){
|
|
|
212 |
// summary:
|
|
|
213 |
// event fired when mouse moves over a header cell.
|
|
|
214 |
// e: decorated event object
|
|
|
215 |
// contains reference to grid, cell, and rowIndex
|
|
|
216 |
dojo.addClass(e.cellNode, this.cellOverClass);
|
|
|
217 |
},
|
|
|
218 |
onHeaderCellMouseOut: function(e){
|
|
|
219 |
// summary:
|
|
|
220 |
// event fired when mouse moves out of a header cell.
|
|
|
221 |
// e: decorated event object
|
|
|
222 |
// contains reference to grid, cell, and rowIndex
|
|
|
223 |
dojo.removeClass(e.cellNode, this.cellOverClass);
|
|
|
224 |
},
|
|
|
225 |
onHeaderClick: function(e){
|
|
|
226 |
// summary:
|
|
|
227 |
// event fired when the grid header is clicked.
|
|
|
228 |
// e: decorated event object
|
|
|
229 |
// contains reference to grid, cell, and rowIndex
|
|
|
230 |
},
|
|
|
231 |
onHeaderCellClick: function(e){
|
|
|
232 |
// summary:
|
|
|
233 |
// event fired when a header cell is clicked.
|
|
|
234 |
// e: decorated event object
|
|
|
235 |
// contains reference to grid, cell, and rowIndex
|
|
|
236 |
this.setSortIndex(e.cell.index);
|
|
|
237 |
this.onHeaderClick(e);
|
|
|
238 |
},
|
|
|
239 |
onHeaderDblClick: function(e){
|
|
|
240 |
// summary:
|
|
|
241 |
// event fired when the grid header is double clicked.
|
|
|
242 |
// e: decorated event object
|
|
|
243 |
// contains reference to grid, cell, and rowIndex
|
|
|
244 |
},
|
|
|
245 |
onHeaderCellDblClick: function(e){
|
|
|
246 |
// summary:
|
|
|
247 |
// event fired when a header cell is double clicked.
|
|
|
248 |
// e: decorated event object
|
|
|
249 |
// contains reference to grid, cell, and rowIndex
|
|
|
250 |
this.onHeaderDblClick(e);
|
|
|
251 |
},
|
|
|
252 |
onHeaderCellContextMenu: function(e){
|
|
|
253 |
// summary:
|
|
|
254 |
// event fired when a header cell context menu is accessed via mouse right click.
|
|
|
255 |
// e: decorated event object
|
|
|
256 |
// contains reference to grid, cell, and rowIndex
|
|
|
257 |
this.onHeaderContextMenu(e);
|
|
|
258 |
},
|
|
|
259 |
onHeaderContextMenu: function(e){
|
|
|
260 |
// summary:
|
|
|
261 |
// event fired when the grid header context menu is accessed via mouse right click.
|
|
|
262 |
// e: decorated event object
|
|
|
263 |
// contains reference to grid, cell, and rowIndex
|
|
|
264 |
dojo.stopEvent(e);
|
|
|
265 |
},
|
|
|
266 |
// editing
|
|
|
267 |
onStartEdit: function(inCell, inRowIndex){
|
|
|
268 |
// summary:
|
|
|
269 |
// event fired when editing is started for a given grid cell
|
|
|
270 |
// inCell: object
|
|
|
271 |
// cell object containing properties of the grid column.
|
|
|
272 |
// inRowIndex: int
|
|
|
273 |
// index of the grid row
|
|
|
274 |
},
|
|
|
275 |
onApplyCellEdit: function(inValue, inRowIndex, inFieldIndex){
|
|
|
276 |
// summary:
|
|
|
277 |
// event fired when editing is applied for a given grid cell
|
|
|
278 |
// inValue: string
|
|
|
279 |
// value from cell editor
|
|
|
280 |
// inRowIndex: int
|
|
|
281 |
// index of the grid row
|
|
|
282 |
// inFieldIndex: int
|
|
|
283 |
// index in the grid's data model
|
|
|
284 |
},
|
|
|
285 |
onCancelEdit: function(inRowIndex){
|
|
|
286 |
// summary:
|
|
|
287 |
// event fired when editing is cancelled for a given grid cell
|
|
|
288 |
// inRowIndex: int
|
|
|
289 |
// index of the grid row
|
|
|
290 |
},
|
|
|
291 |
onApplyEdit: function(inRowIndex){
|
|
|
292 |
// summary:
|
|
|
293 |
// event fired when editing is applied for a given grid row
|
|
|
294 |
// inRowIndex: int
|
|
|
295 |
// index of the grid row
|
|
|
296 |
},
|
|
|
297 |
onCanSelect: function(inRowIndex){
|
|
|
298 |
// summary:
|
|
|
299 |
// event to determine if a grid row may be selected
|
|
|
300 |
// inRowIndex: int
|
|
|
301 |
// index of the grid row
|
|
|
302 |
// returns:
|
|
|
303 |
// true if the row can be selected
|
|
|
304 |
return true // boolean;
|
|
|
305 |
},
|
|
|
306 |
onCanDeselect: function(inRowIndex){
|
|
|
307 |
// summary:
|
|
|
308 |
// event to determine if a grid row may be deselected
|
|
|
309 |
// inRowIndex: int
|
|
|
310 |
// index of the grid row
|
|
|
311 |
// returns:
|
|
|
312 |
// true if the row can be deselected
|
|
|
313 |
return true // boolean;
|
|
|
314 |
},
|
|
|
315 |
onSelected: function(inRowIndex){
|
|
|
316 |
// summary:
|
|
|
317 |
// event fired when a grid row is selected
|
|
|
318 |
// inRowIndex: int
|
|
|
319 |
// index of the grid row
|
|
|
320 |
this.updateRowStyles(inRowIndex);
|
|
|
321 |
},
|
|
|
322 |
onDeselected: function(inRowIndex){
|
|
|
323 |
// summary:
|
|
|
324 |
// event fired when a grid row is deselected
|
|
|
325 |
// inRowIndex: int
|
|
|
326 |
// index of the grid row
|
|
|
327 |
this.updateRowStyles(inRowIndex);
|
|
|
328 |
},
|
|
|
329 |
onSelectionChanged: function(){
|
|
|
330 |
}
|
|
|
331 |
}
|
|
|
332 |
|
|
|
333 |
}
|