2150 |
mathias |
1 |
if(!dojo._hasResource["dojox.grid._grid.cell"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
|
|
|
2 |
dojo._hasResource["dojox.grid._grid.cell"] = true;
|
|
|
3 |
dojo.provide("dojox.grid._grid.cell");
|
|
|
4 |
|
|
|
5 |
dojo.declare("dojox.grid.cell", null, {
|
|
|
6 |
// summary:
|
|
|
7 |
// Respresents a grid cell and contains information about column options and methods
|
|
|
8 |
// for retrieving cell related information.
|
|
|
9 |
// Each column in a grid layout has a cell object and most events and many methods
|
|
|
10 |
// provide access to these objects.
|
|
|
11 |
styles: '',
|
|
|
12 |
constructor: function(inProps){
|
|
|
13 |
dojo.mixin(this, inProps);
|
|
|
14 |
if(this.editor){this.editor = new this.editor(this);}
|
|
|
15 |
},
|
|
|
16 |
// data source
|
|
|
17 |
format: function(inRowIndex){
|
|
|
18 |
// summary:
|
|
|
19 |
// provides the html for a given grid cell.
|
|
|
20 |
// inRowIndex: int
|
|
|
21 |
// grid row index
|
|
|
22 |
// returns: html for a given grid cell
|
|
|
23 |
var f, i=this.grid.edit.info, d=this.get ? this.get(inRowIndex) : this.value;
|
|
|
24 |
if(this.editor && (this.editor.alwaysOn || (i.rowIndex==inRowIndex && i.cell==this))){
|
|
|
25 |
return this.editor.format(d, inRowIndex);
|
|
|
26 |
}else{
|
|
|
27 |
return (f = this.formatter) ? f.call(this, d, inRowIndex) : d;
|
|
|
28 |
}
|
|
|
29 |
},
|
|
|
30 |
// utility
|
|
|
31 |
getNode: function(inRowIndex){
|
|
|
32 |
// summary:
|
|
|
33 |
// gets the dom node for a given grid cell.
|
|
|
34 |
// inRowIndex: int
|
|
|
35 |
// grid row index
|
|
|
36 |
// returns: dom node for a given grid cell
|
|
|
37 |
return this.view.getCellNode(inRowIndex, this.index);
|
|
|
38 |
},
|
|
|
39 |
isFlex: function(){
|
|
|
40 |
var uw = this.unitWidth;
|
|
|
41 |
return uw && (uw=='auto' || uw.slice(-1)=='%');
|
|
|
42 |
},
|
|
|
43 |
// edit support
|
|
|
44 |
applyEdit: function(inValue, inRowIndex){
|
|
|
45 |
this.grid.edit.applyCellEdit(inValue, this, inRowIndex);
|
|
|
46 |
},
|
|
|
47 |
cancelEdit: function(inRowIndex){
|
|
|
48 |
this.grid.doCancelEdit(inRowIndex);
|
|
|
49 |
},
|
|
|
50 |
_onEditBlur: function(inRowIndex){
|
|
|
51 |
if(this.grid.edit.isEditCell(inRowIndex, this.index)){
|
|
|
52 |
//console.log('editor onblur', e);
|
|
|
53 |
this.grid.edit.apply();
|
|
|
54 |
}
|
|
|
55 |
},
|
|
|
56 |
registerOnBlur: function(inNode, inRowIndex){
|
|
|
57 |
if(this.commitOnBlur){
|
|
|
58 |
dojo.connect(inNode, "onblur", function(e){
|
|
|
59 |
// hack: if editor still thinks this editor is current some ms after it blurs, assume we've focused away from grid
|
|
|
60 |
setTimeout(dojo.hitch(this, "_onEditBlur", inRowIndex), 250);
|
|
|
61 |
});
|
|
|
62 |
}
|
|
|
63 |
}
|
|
|
64 |
});
|
|
|
65 |
|
|
|
66 |
}
|