root / trunk / web / dojo / dojox / grid / _Grid.js @ 12
History | View | Annotate | Download (19.4 KB)
1 | 9 | andrej.cim | /*
|
---|---|---|---|
2 | Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
||
3 | Available via Academic Free License >= 2.1 OR the modified BSD license.
|
||
4 | see: http://dojotoolkit.org/license for details
|
||
5 | */
|
||
6 | |||
7 | |||
8 | if(!dojo._hasResource["dojox.grid._Grid"]){ |
||
9 | dojo._hasResource["dojox.grid._Grid"]=true; |
||
10 | dojo.provide("dojox.grid._Grid");
|
||
11 | dojo.require("dijit.dijit");
|
||
12 | dojo.require("dijit.Menu");
|
||
13 | dojo.require("dojox.html.metrics");
|
||
14 | dojo.require("dojox.grid.util");
|
||
15 | dojo.require("dojox.grid._Scroller");
|
||
16 | dojo.require("dojox.grid._Layout");
|
||
17 | dojo.require("dojox.grid._View");
|
||
18 | dojo.require("dojox.grid._ViewManager");
|
||
19 | dojo.require("dojox.grid._RowManager");
|
||
20 | dojo.require("dojox.grid._FocusManager");
|
||
21 | dojo.require("dojox.grid._EditManager");
|
||
22 | dojo.require("dojox.grid.Selection");
|
||
23 | dojo.require("dojox.grid._RowSelector");
|
||
24 | dojo.require("dojox.grid._Events");
|
||
25 | dojo.requireLocalization("dijit","loading",null,"ROOT,ar,ca,cs,da,de,el,es,fi,fr,he,hu,it,ja,ko,nb,nl,pl,pt,pt-pt,ro,ru,sk,sl,sv,th,tr,zh,zh-tw"); |
||
26 | (function(){
|
||
27 | if(!dojo.isCopyKey){
|
||
28 | dojo.isCopyKey=dojo.dnd.getCopyKeyState; |
||
29 | } |
||
30 | dojo.declare("dojox.grid._Grid",[dijit._Widget,dijit._Templated,dojox.grid._Events],{templateString:"<div hidefocus=\"hidefocus\" wairole=\"grid\" dojoAttachEvent=\"onmouseout:_mouseOut\">\n\t<div class=\"dojoxGridMasterHeader\" dojoAttachPoint=\"viewsHeaderNode\" wairole=\"presentation\"></div>\n\t<div class=\"dojoxGridMasterView\" dojoAttachPoint=\"viewsNode\" wairole=\"presentation\"></div>\n\t<div class=\"dojoxGridMasterMessages\" style=\"display: none;\" dojoAttachPoint=\"messagesNode\"></div>\n\t<span dojoAttachPoint=\"lastFocusNode\" tabindex=\"0\"></span>\n</div>\n",classTag:"dojoxGrid",rowCount:5,keepRows:75,rowsPerPage:25,autoWidth:false,initialWidth:"",autoHeight:"",rowHeight:0,autoRender:true,defaultHeight:"15em",height:"",structure:null,elasticView:-1,singleClickEdit:false,selectionMode:"extended",rowSelector:"",columnReordering:false,headerMenu:null,placeholderLabel:"GridColumns",selectable:false,_click:null,loadingMessage:"<span class='dojoxGridLoading'>${loadingState}</span>",errorMessage:"<span class='dojoxGridError'>${errorState}</span>",noDataMessage:"",escapeHTMLInData:true,formatterScope:null,editable:false,sortInfo:0,themeable:true,_placeholders:null,_layoutClass:dojox.grid._Layout,buildRendering:function(){ |
||
31 | this.inherited(arguments); |
||
32 | if(!this.domNode.getAttribute("tabIndex")){ |
||
33 | this.domNode.tabIndex="0"; |
||
34 | } |
||
35 | this.createScroller();
|
||
36 | this.createLayout();
|
||
37 | this.createViews();
|
||
38 | this.createManagers();
|
||
39 | this.createSelection();
|
||
40 | this.connect(this.selection,"onSelected","onSelected"); |
||
41 | this.connect(this.selection,"onDeselected","onDeselected"); |
||
42 | this.connect(this.selection,"onChanged","onSelectionChanged"); |
||
43 | dojox.html.metrics.initOnFontResize(); |
||
44 | this.connect(dojox.html.metrics,"onFontResize","textSizeChanged"); |
||
45 | dojox.grid.util.funnelEvents(this.domNode,this,"doKeyEvent",dojox.grid.util.keyEvents); |
||
46 | if(this.selectionMode!="none"){ |
||
47 | dojo.attr(this.domNode,"aria-multiselectable",this.selectionMode=="single"?"false":"true"); |
||
48 | } |
||
49 | dojo.addClass(this.domNode,this.classTag); |
||
50 | if(!this.isLeftToRight()){ |
||
51 | dojo.addClass(this.domNode,this.classTag+"Rtl"); |
||
52 | } |
||
53 | },postMixInProperties:function(){ |
||
54 | this.inherited(arguments); |
||
55 | var _1=dojo.i18n.getLocalization("dijit","loading",this.lang); |
||
56 | this.loadingMessage=dojo.string.substitute(this.loadingMessage,_1); |
||
57 | this.errorMessage=dojo.string.substitute(this.errorMessage,_1); |
||
58 | if(this.srcNodeRef&&this.srcNodeRef.style.height){ |
||
59 | this.height=this.srcNodeRef.style.height; |
||
60 | } |
||
61 | this._setAutoHeightAttr(this.autoHeight,true); |
||
62 | this.lastScrollTop=this.scrollTop=0; |
||
63 | },postCreate:function(){ |
||
64 | this._placeholders=[];
|
||
65 | this._setHeaderMenuAttr(this.headerMenu); |
||
66 | this._setStructureAttr(this.structure); |
||
67 | this._click=[];
|
||
68 | this.inherited(arguments); |
||
69 | if(this.domNode&&this.autoWidth&&this.initialWidth){ |
||
70 | this.domNode.style.width=this.initialWidth; |
||
71 | } |
||
72 | if(this.domNode&&!this.editable){ |
||
73 | dojo.attr(this.domNode,"aria-readonly","true"); |
||
74 | } |
||
75 | },destroy:function(){ |
||
76 | this.domNode.onReveal=null; |
||
77 | this.domNode.onSizeChange=null; |
||
78 | delete this._click; |
||
79 | this.edit.destroy();
|
||
80 | delete this.edit; |
||
81 | this.views.destroyViews();
|
||
82 | if(this.scroller){ |
||
83 | this.scroller.destroy();
|
||
84 | delete this.scroller; |
||
85 | } |
||
86 | if(this.focus){ |
||
87 | this.focus.destroy();
|
||
88 | delete this.focus; |
||
89 | } |
||
90 | if(this.headerMenu&&this._placeholders.length){ |
||
91 | dojo.forEach(this._placeholders,function(p){ |
||
92 | p.unReplace(true);
|
||
93 | }); |
||
94 | this.headerMenu.unBindDomNode(this.viewsHeaderNode); |
||
95 | } |
||
96 | this.inherited(arguments); |
||
97 | },_setAutoHeightAttr:function(ah,_2){ |
||
98 | if(typeof ah=="string"){ |
||
99 | if(!ah||ah=="false"){ |
||
100 | ah=false;
|
||
101 | }else{
|
||
102 | if(ah=="true"){ |
||
103 | ah=true;
|
||
104 | }else{
|
||
105 | ah=window.parseInt(ah,10);
|
||
106 | } |
||
107 | } |
||
108 | } |
||
109 | if(typeof ah=="number"){ |
||
110 | if(isNaN(ah)){
|
||
111 | ah=false;
|
||
112 | } |
||
113 | if(ah<0){ |
||
114 | ah=true;
|
||
115 | }else{
|
||
116 | if(ah===0){ |
||
117 | ah=false;
|
||
118 | } |
||
119 | } |
||
120 | } |
||
121 | this.autoHeight=ah;
|
||
122 | if(typeof ah=="boolean"){ |
||
123 | this._autoHeight=ah;
|
||
124 | }else{
|
||
125 | if(typeof ah=="number"){ |
||
126 | this._autoHeight=(ah>=this.get("rowCount")); |
||
127 | }else{
|
||
128 | this._autoHeight=false; |
||
129 | } |
||
130 | } |
||
131 | if(this._started&&!_2){ |
||
132 | this.render();
|
||
133 | } |
||
134 | },_getRowCountAttr:function(){ |
||
135 | return this.updating&&this.invalidated&&this.invalidated.rowCount!=undefined?this.invalidated.rowCount:this.rowCount; |
||
136 | },textSizeChanged:function(){ |
||
137 | this.render();
|
||
138 | },sizeChange:function(){ |
||
139 | this.update();
|
||
140 | },createManagers:function(){ |
||
141 | this.rows=new dojox.grid._RowManager(this); |
||
142 | this.focus=new dojox.grid._FocusManager(this); |
||
143 | this.edit=new dojox.grid._EditManager(this); |
||
144 | },createSelection:function(){ |
||
145 | this.selection=new dojox.grid.Selection(this); |
||
146 | },createScroller:function(){ |
||
147 | this.scroller=new dojox.grid._Scroller(); |
||
148 | this.scroller.grid=this; |
||
149 | this.scroller.renderRow=dojo.hitch(this,"renderRow"); |
||
150 | this.scroller.removeRow=dojo.hitch(this,"rowRemoved"); |
||
151 | },createLayout:function(){ |
||
152 | this.layout=new this._layoutClass(this); |
||
153 | this.connect(this.layout,"moveColumn","onMoveColumn"); |
||
154 | },onMoveColumn:function(){ |
||
155 | this.render();
|
||
156 | },onResizeColumn:function(_3){ |
||
157 | },createViews:function(){ |
||
158 | this.views=new dojox.grid._ViewManager(this); |
||
159 | this.views.createView=dojo.hitch(this,"createView"); |
||
160 | },createView:function(_4,_5){ |
||
161 | var c=dojo.getObject(_4);
|
||
162 | var _6=new c({grid:this,index:_5}); |
||
163 | this.viewsNode.appendChild(_6.domNode);
|
||
164 | this.viewsHeaderNode.appendChild(_6.headerNode);
|
||
165 | this.views.addView(_6);
|
||
166 | return _6;
|
||
167 | },buildViews:function(){ |
||
168 | for(var i=0,vs;(vs=this.layout.structure[i]);i++){ |
||
169 | this.createView(vs.type||dojox._scopeName+".grid._View",i).setStructure(vs); |
||
170 | } |
||
171 | this.scroller.setContentNodes(this.views.getContentNodes()); |
||
172 | },_setStructureAttr:function(_7){ |
||
173 | var s=_7;
|
||
174 | if(s&&dojo.isString(s)){
|
||
175 | dojo.deprecated("dojox.grid._Grid.attr('structure', 'objVar')","use dojox.grid._Grid.attr('structure', objVar) instead","2.0"); |
||
176 | s=dojo.getObject(s); |
||
177 | } |
||
178 | this.structure=s;
|
||
179 | if(!s){
|
||
180 | if(this.layout.structure){ |
||
181 | s=this.layout.structure;
|
||
182 | }else{
|
||
183 | return;
|
||
184 | } |
||
185 | } |
||
186 | this.views.destroyViews();
|
||
187 | if(s!==this.layout.structure){ |
||
188 | this.layout.setStructure(s);
|
||
189 | } |
||
190 | this._structureChanged();
|
||
191 | },setStructure:function(_8){ |
||
192 | dojo.deprecated("dojox.grid._Grid.setStructure(obj)","use dojox.grid._Grid.attr('structure', obj) instead.","2.0"); |
||
193 | this._setStructureAttr(_8);
|
||
194 | },getColumnTogglingItems:function(){ |
||
195 | return dojo.map(this.layout.cells,function(_9){ |
||
196 | if(!_9.menuItems){
|
||
197 | _9.menuItems=[]; |
||
198 | } |
||
199 | var _a=this; |
||
200 | var _b=new dijit.CheckedMenuItem({label:_9.name,checked:!_9.hidden,_gridCell:_9,onChange:function(_c){ |
||
201 | if(_a.layout.setColumnVisibility(this._gridCell.index,_c)){ |
||
202 | var _d=this._gridCell.menuItems; |
||
203 | if(_d.length>1){ |
||
204 | dojo.forEach(_d,function(_e){
|
||
205 | if(_e!==this){ |
||
206 | _e.setAttribute("checked",_c);
|
||
207 | } |
||
208 | },this);
|
||
209 | } |
||
210 | _c=dojo.filter(_a.layout.cells,function(c){
|
||
211 | if(c.menuItems.length>1){ |
||
212 | dojo.forEach(c.menuItems,"item.attr('disabled', false);");
|
||
213 | }else{
|
||
214 | c.menuItems[0].attr("disabled",false); |
||
215 | } |
||
216 | return !c.hidden;
|
||
217 | }); |
||
218 | if(_c.length==1){ |
||
219 | dojo.forEach(_c[0].menuItems,"item.attr('disabled', true);"); |
||
220 | } |
||
221 | } |
||
222 | },destroy:function(){ |
||
223 | var _f=dojo.indexOf(this._gridCell.menuItems,this); |
||
224 | this._gridCell.menuItems.splice(_f,1); |
||
225 | delete this._gridCell; |
||
226 | dijit.CheckedMenuItem.prototype.destroy.apply(this,arguments); |
||
227 | }}); |
||
228 | _9.menuItems.push(_b); |
||
229 | return _b;
|
||
230 | },this);
|
||
231 | },_setHeaderMenuAttr:function(_10){ |
||
232 | if(this._placeholders&&this._placeholders.length){ |
||
233 | dojo.forEach(this._placeholders,function(p){ |
||
234 | p.unReplace(true);
|
||
235 | }); |
||
236 | this._placeholders=[];
|
||
237 | } |
||
238 | if(this.headerMenu){ |
||
239 | this.headerMenu.unBindDomNode(this.viewsHeaderNode); |
||
240 | } |
||
241 | this.headerMenu=_10;
|
||
242 | if(!_10){
|
||
243 | return;
|
||
244 | } |
||
245 | this.headerMenu.bindDomNode(this.viewsHeaderNode); |
||
246 | if(this.headerMenu.getPlaceholders){ |
||
247 | this._placeholders=this.headerMenu.getPlaceholders(this.placeholderLabel); |
||
248 | } |
||
249 | },setHeaderMenu:function(_11){ |
||
250 | dojo.deprecated("dojox.grid._Grid.setHeaderMenu(obj)","use dojox.grid._Grid.attr('headerMenu', obj) instead.","2.0"); |
||
251 | this._setHeaderMenuAttr(_11);
|
||
252 | },setupHeaderMenu:function(){ |
||
253 | if(this._placeholders&&this._placeholders.length){ |
||
254 | dojo.forEach(this._placeholders,function(p){ |
||
255 | if(p._replaced){
|
||
256 | p.unReplace(true);
|
||
257 | } |
||
258 | p.replace(this.getColumnTogglingItems());
|
||
259 | },this);
|
||
260 | } |
||
261 | },_fetch:function(_12){ |
||
262 | this.setScrollTop(0); |
||
263 | },getItem:function(_13){ |
||
264 | return null; |
||
265 | },showMessage:function(_14){ |
||
266 | if(_14){
|
||
267 | this.messagesNode.innerHTML=_14;
|
||
268 | this.messagesNode.style.display=""; |
||
269 | }else{
|
||
270 | this.messagesNode.innerHTML=""; |
||
271 | this.messagesNode.style.display="none"; |
||
272 | } |
||
273 | },_structureChanged:function(){ |
||
274 | this.buildViews();
|
||
275 | if(this.autoRender&&this._started){ |
||
276 | this.render();
|
||
277 | } |
||
278 | },hasLayout:function(){ |
||
279 | return this.layout.cells.length; |
||
280 | },resize:function(_15,_16){ |
||
281 | this._pendingChangeSize=_15;
|
||
282 | this._pendingResultSize=_16;
|
||
283 | this.sizeChange();
|
||
284 | },_getPadBorder:function(){ |
||
285 | this._padBorder=this._padBorder||dojo._getPadBorderExtents(this.domNode); |
||
286 | return this._padBorder; |
||
287 | },_getHeaderHeight:function(){ |
||
288 | var vns=this.viewsHeaderNode.style,t=vns.display=="none"?0:this.views.measureHeader(); |
||
289 | vns.height=t+"px";
|
||
290 | this.views.normalizeHeaderNodeHeight();
|
||
291 | return t;
|
||
292 | },_resize:function(_17,_18){ |
||
293 | _17=_17||this._pendingChangeSize;
|
||
294 | _18=_18||this._pendingResultSize;
|
||
295 | delete this._pendingChangeSize; |
||
296 | delete this._pendingResultSize; |
||
297 | if(!this.domNode){ |
||
298 | return;
|
||
299 | } |
||
300 | var pn=this.domNode.parentNode; |
||
301 | if(!pn||pn.nodeType!=1||!this.hasLayout()||pn.style.visibility=="hidden"||pn.style.display=="none"){ |
||
302 | return;
|
||
303 | } |
||
304 | var _19=this._getPadBorder(); |
||
305 | var hh=undefined; |
||
306 | var h;
|
||
307 | if(this._autoHeight){ |
||
308 | this.domNode.style.height="auto"; |
||
309 | this.viewsNode.style.height=""; |
||
310 | }else{
|
||
311 | if(typeof this.autoHeight=="number"){ |
||
312 | h=hh=this._getHeaderHeight();
|
||
313 | h+=(this.scroller.averageRowHeight*this.autoHeight); |
||
314 | this.domNode.style.height=h+"px"; |
||
315 | }else{
|
||
316 | if(this.domNode.clientHeight<=_19.h){ |
||
317 | if(pn==document.body){
|
||
318 | this.domNode.style.height=this.defaultHeight; |
||
319 | }else{
|
||
320 | if(this.height){ |
||
321 | this.domNode.style.height=this.height; |
||
322 | }else{
|
||
323 | this.fitTo="parent"; |
||
324 | } |
||
325 | } |
||
326 | } |
||
327 | } |
||
328 | } |
||
329 | if(_18){
|
||
330 | _17=_18; |
||
331 | } |
||
332 | if(_17){
|
||
333 | dojo.marginBox(this.domNode,_17);
|
||
334 | this.height=this.domNode.style.height; |
||
335 | delete this.fitTo; |
||
336 | }else{
|
||
337 | if(this.fitTo=="parent"){ |
||
338 | h=this._parentContentBoxHeight=this._parentContentBoxHeight||dojo._getContentBox(pn).h; |
||
339 | this.domNode.style.height=Math.max(0,h)+"px"; |
||
340 | } |
||
341 | } |
||
342 | var _1a=dojo.some(this.views.views,function(v){ |
||
343 | return v.flexCells;
|
||
344 | }); |
||
345 | if(!this._autoHeight&&(h||dojo._getContentBox(this.domNode).h)===0){ |
||
346 | this.viewsHeaderNode.style.display="none"; |
||
347 | }else{
|
||
348 | this.viewsHeaderNode.style.display="block"; |
||
349 | if(!_1a&&hh===undefined){ |
||
350 | hh=this._getHeaderHeight();
|
||
351 | } |
||
352 | } |
||
353 | if(_1a){
|
||
354 | hh=undefined;
|
||
355 | } |
||
356 | this.adaptWidth();
|
||
357 | this.adaptHeight(hh);
|
||
358 | this.postresize();
|
||
359 | },adaptWidth:function(){ |
||
360 | var _1b=(!this.initialWidth&&this.autoWidth); |
||
361 | var w=_1b?0:this.domNode.clientWidth||(this.domNode.offsetWidth-this._getPadBorder().w),vw=this.views.arrange(1,w); |
||
362 | this.views.onEach("adaptWidth"); |
||
363 | if(_1b){
|
||
364 | this.domNode.style.width=vw+"px"; |
||
365 | } |
||
366 | },adaptHeight:function(_1c){ |
||
367 | var t=_1c===undefined?this._getHeaderHeight():_1c; |
||
368 | var h=(this._autoHeight?-1:Math.max(this.domNode.clientHeight-t,0)||0); |
||
369 | this.views.onEach("setSize",[0,h]); |
||
370 | this.views.onEach("adaptHeight"); |
||
371 | if(!this._autoHeight){ |
||
372 | var _1d=0,_1e=0; |
||
373 | var _1f=dojo.filter(this.views.views,function(v){ |
||
374 | var has=v.hasHScrollbar();
|
||
375 | if(has){
|
||
376 | _1d++; |
||
377 | }else{
|
||
378 | _1e++; |
||
379 | } |
||
380 | return (!has);
|
||
381 | }); |
||
382 | if(_1d>0&&_1e>0){ |
||
383 | dojo.forEach(_1f,function(v){
|
||
384 | v.adaptHeight(true);
|
||
385 | }); |
||
386 | } |
||
387 | } |
||
388 | if(this.autoHeight===true||h!=-1||(typeof this.autoHeight=="number"&&this.autoHeight>=this.get("rowCount"))){ |
||
389 | this.scroller.windowHeight=h;
|
||
390 | }else{
|
||
391 | this.scroller.windowHeight=Math.max(this.domNode.clientHeight-t,0); |
||
392 | } |
||
393 | },startup:function(){ |
||
394 | if(this._started){ |
||
395 | return;
|
||
396 | } |
||
397 | this.inherited(arguments); |
||
398 | if(this.autoRender){ |
||
399 | this.render();
|
||
400 | } |
||
401 | },render:function(){ |
||
402 | if(!this.domNode){ |
||
403 | return;
|
||
404 | } |
||
405 | if(!this._started){ |
||
406 | return;
|
||
407 | } |
||
408 | if(!this.hasLayout()){ |
||
409 | this.scroller.init(0,this.keepRows,this.rowsPerPage); |
||
410 | return;
|
||
411 | } |
||
412 | this.update=this.defaultUpdate; |
||
413 | this._render();
|
||
414 | },_render:function(){ |
||
415 | this.scroller.init(this.get("rowCount"),this.keepRows,this.rowsPerPage); |
||
416 | this.prerender();
|
||
417 | this.setScrollTop(0); |
||
418 | this.postrender();
|
||
419 | },prerender:function(){ |
||
420 | this.keepRows=this._autoHeight?0:this.keepRows; |
||
421 | this.scroller.setKeepInfo(this.keepRows); |
||
422 | this.views.render();
|
||
423 | this._resize();
|
||
424 | },postrender:function(){ |
||
425 | this.postresize();
|
||
426 | this.focus.initFocusView();
|
||
427 | dojo.setSelectable(this.domNode,this.selectable); |
||
428 | },postresize:function(){ |
||
429 | if(this._autoHeight){ |
||
430 | var _20=Math.max(this.views.measureContent())+"px"; |
||
431 | this.viewsNode.style.height=_20;
|
||
432 | } |
||
433 | },renderRow:function(_21,_22){ |
||
434 | this.views.renderRow(_21,_22,this._skipRowRenormalize); |
||
435 | },rowRemoved:function(_23){ |
||
436 | this.views.rowRemoved(_23);
|
||
437 | },invalidated:null,updating:false,beginUpdate:function(){ |
||
438 | this.invalidated=[];
|
||
439 | this.updating=true; |
||
440 | },endUpdate:function(){ |
||
441 | this.updating=false; |
||
442 | var i=this.invalidated,r; |
||
443 | if(i.all){
|
||
444 | this.update();
|
||
445 | }else{
|
||
446 | if(i.rowCount!=undefined){ |
||
447 | this.updateRowCount(i.rowCount);
|
||
448 | }else{
|
||
449 | for(r in i){ |
||
450 | this.updateRow(Number(r));
|
||
451 | } |
||
452 | } |
||
453 | } |
||
454 | this.invalidated=[];
|
||
455 | },defaultUpdate:function(){ |
||
456 | if(!this.domNode){ |
||
457 | return;
|
||
458 | } |
||
459 | if(this.updating){ |
||
460 | this.invalidated.all=true; |
||
461 | return;
|
||
462 | } |
||
463 | this.lastScrollTop=this.scrollTop; |
||
464 | this.prerender();
|
||
465 | this.scroller.invalidateNodes();
|
||
466 | this.setScrollTop(this.lastScrollTop); |
||
467 | this.postrender();
|
||
468 | },update:function(){ |
||
469 | this.render();
|
||
470 | },updateRow:function(_24){ |
||
471 | _24=Number(_24); |
||
472 | if(this.updating){ |
||
473 | this.invalidated[_24]=true; |
||
474 | }else{
|
||
475 | this.views.updateRow(_24);
|
||
476 | this.scroller.rowHeightChanged(_24);
|
||
477 | } |
||
478 | },updateRows:function(_25,_26){ |
||
479 | _25=Number(_25); |
||
480 | _26=Number(_26); |
||
481 | var i;
|
||
482 | if(this.updating){ |
||
483 | for(i=0;i<_26;i++){ |
||
484 | this.invalidated[i+_25]=true; |
||
485 | } |
||
486 | }else{
|
||
487 | for(i=0;i<_26;i++){ |
||
488 | this.views.updateRow(i+_25,this._skipRowRenormalize); |
||
489 | } |
||
490 | this.scroller.rowHeightChanged(_25);
|
||
491 | } |
||
492 | },updateRowCount:function(_27){ |
||
493 | if(this.updating){ |
||
494 | this.invalidated.rowCount=_27;
|
||
495 | }else{
|
||
496 | this.rowCount=_27;
|
||
497 | this._setAutoHeightAttr(this.autoHeight,true); |
||
498 | if(this.layout.cells.length){ |
||
499 | this.scroller.updateRowCount(_27);
|
||
500 | } |
||
501 | this._resize();
|
||
502 | if(this.layout.cells.length){ |
||
503 | this.setScrollTop(this.scrollTop); |
||
504 | } |
||
505 | } |
||
506 | },updateRowStyles:function(_28){ |
||
507 | this.views.updateRowStyles(_28);
|
||
508 | },getRowNode:function(_29){ |
||
509 | if(this.focus.focusView&&!(this.focus.focusView instanceof dojox.grid._RowSelector)){ |
||
510 | return this.focus.focusView.rowNodes[_29]; |
||
511 | }else{
|
||
512 | for(var i=0,_2a;(_2a=this.views.views[i]);i++){ |
||
513 | if(!(_2a instanceof dojox.grid._RowSelector)){ |
||
514 | return _2a.rowNodes[_29];
|
||
515 | } |
||
516 | } |
||
517 | } |
||
518 | return null; |
||
519 | },rowHeightChanged:function(_2b){ |
||
520 | this.views.renormalizeRow(_2b);
|
||
521 | this.scroller.rowHeightChanged(_2b);
|
||
522 | },fastScroll:true,delayScroll:false,scrollRedrawThreshold:(dojo.isIE?100:50),scrollTo:function(_2c){ |
||
523 | if(!this.fastScroll){ |
||
524 | this.setScrollTop(_2c);
|
||
525 | return;
|
||
526 | } |
||
527 | var _2d=Math.abs(this.lastScrollTop-_2c); |
||
528 | this.lastScrollTop=_2c;
|
||
529 | if(_2d>this.scrollRedrawThreshold||this.delayScroll){ |
||
530 | this.delayScroll=true; |
||
531 | this.scrollTop=_2c;
|
||
532 | this.views.setScrollTop(_2c);
|
||
533 | if(this._pendingScroll){ |
||
534 | window.clearTimeout(this._pendingScroll);
|
||
535 | } |
||
536 | var _2e=this; |
||
537 | this._pendingScroll=window.setTimeout(function(){ |
||
538 | delete _2e._pendingScroll;
|
||
539 | _2e.finishScrollJob(); |
||
540 | },200);
|
||
541 | }else{
|
||
542 | this.setScrollTop(_2c);
|
||
543 | } |
||
544 | },finishScrollJob:function(){ |
||
545 | this.delayScroll=false; |
||
546 | this.setScrollTop(this.scrollTop); |
||
547 | },setScrollTop:function(_2f){ |
||
548 | this.scroller.scroll(this.views.setScrollTop(_2f)); |
||
549 | },scrollToRow:function(_30){ |
||
550 | this.setScrollTop(this.scroller.findScrollTop(_30)+1); |
||
551 | },styleRowNode:function(_31,_32){ |
||
552 | if(_32){
|
||
553 | this.rows.styleRowNode(_31,_32);
|
||
554 | } |
||
555 | },_mouseOut:function(e){ |
||
556 | this.rows.setOverRow(-2); |
||
557 | },getCell:function(_33){ |
||
558 | return this.layout.cells[_33]; |
||
559 | },setCellWidth:function(_34,_35){ |
||
560 | this.getCell(_34).unitWidth=_35;
|
||
561 | },getCellName:function(_36){ |
||
562 | return "Cell "+_36.index; |
||
563 | },canSort:function(_37){ |
||
564 | },sort:function(){ |
||
565 | },getSortAsc:function(_38){ |
||
566 | _38=_38==undefined?this.sortInfo:_38; |
||
567 | return Boolean(_38>0); |
||
568 | },getSortIndex:function(_39){ |
||
569 | _39=_39==undefined?this.sortInfo:_39; |
||
570 | return Math.abs(_39)-1; |
||
571 | },setSortIndex:function(_3a,_3b){ |
||
572 | var si=_3a+1; |
||
573 | if(_3b!=undefined){ |
||
574 | si*=(_3b?1:-1); |
||
575 | }else{
|
||
576 | if(this.getSortIndex()==_3a){ |
||
577 | si=-this.sortInfo;
|
||
578 | } |
||
579 | } |
||
580 | this.setSortInfo(si);
|
||
581 | },setSortInfo:function(_3c){ |
||
582 | if(this.canSort(_3c)){ |
||
583 | this.sortInfo=_3c;
|
||
584 | this.sort();
|
||
585 | this.update();
|
||
586 | } |
||
587 | },doKeyEvent:function(e){ |
||
588 | e.dispatch="do"+e.type;
|
||
589 | this.onKeyEvent(e);
|
||
590 | },_dispatch:function(m,e){ |
||
591 | if(m in this){ |
||
592 | return this[m](e); |
||
593 | } |
||
594 | return false; |
||
595 | },dispatchKeyEvent:function(e){ |
||
596 | this._dispatch(e.dispatch,e);
|
||
597 | },dispatchContentEvent:function(e){ |
||
598 | this.edit.dispatchEvent(e)||e.sourceView.dispatchContentEvent(e)||this._dispatch(e.dispatch,e); |
||
599 | },dispatchHeaderEvent:function(e){ |
||
600 | e.sourceView.dispatchHeaderEvent(e)||this._dispatch("doheader"+e.type,e); |
||
601 | },dokeydown:function(e){ |
||
602 | this.onKeyDown(e);
|
||
603 | },doclick:function(e){ |
||
604 | if(e.cellNode){
|
||
605 | this.onCellClick(e);
|
||
606 | }else{
|
||
607 | this.onRowClick(e);
|
||
608 | } |
||
609 | },dodblclick:function(e){ |
||
610 | if(e.cellNode){
|
||
611 | this.onCellDblClick(e);
|
||
612 | }else{
|
||
613 | this.onRowDblClick(e);
|
||
614 | } |
||
615 | },docontextmenu:function(e){ |
||
616 | if(e.cellNode){
|
||
617 | this.onCellContextMenu(e);
|
||
618 | }else{
|
||
619 | this.onRowContextMenu(e);
|
||
620 | } |
||
621 | },doheaderclick:function(e){ |
||
622 | if(e.cellNode){
|
||
623 | this.onHeaderCellClick(e);
|
||
624 | }else{
|
||
625 | this.onHeaderClick(e);
|
||
626 | } |
||
627 | },doheaderdblclick:function(e){ |
||
628 | if(e.cellNode){
|
||
629 | this.onHeaderCellDblClick(e);
|
||
630 | }else{
|
||
631 | this.onHeaderDblClick(e);
|
||
632 | } |
||
633 | },doheadercontextmenu:function(e){ |
||
634 | if(e.cellNode){
|
||
635 | this.onHeaderCellContextMenu(e);
|
||
636 | }else{
|
||
637 | this.onHeaderContextMenu(e);
|
||
638 | } |
||
639 | },doStartEdit:function(_3d,_3e){ |
||
640 | this.onStartEdit(_3d,_3e);
|
||
641 | },doApplyCellEdit:function(_3f,_40,_41){ |
||
642 | this.onApplyCellEdit(_3f,_40,_41);
|
||
643 | },doCancelEdit:function(_42){ |
||
644 | this.onCancelEdit(_42);
|
||
645 | },doApplyEdit:function(_43){ |
||
646 | this.onApplyEdit(_43);
|
||
647 | },addRow:function(){ |
||
648 | this.updateRowCount(this.get("rowCount")+1); |
||
649 | },removeSelectedRows:function(){ |
||
650 | if(this.allItemsSelected){ |
||
651 | this.updateRowCount(0); |
||
652 | }else{
|
||
653 | this.updateRowCount(Math.max(0,this.get("rowCount")-this.selection.getSelected().length)); |
||
654 | } |
||
655 | this.selection.clear();
|
||
656 | }}); |
||
657 | dojox.grid._Grid.markupFactory=function(_44,_45,_46,_47){ |
||
658 | var d=dojo;
|
||
659 | var _48=function(n){ |
||
660 | var w=d.attr(n,"width")||"auto"; |
||
661 | if((w!="auto")&&(w.slice(-2)!="em")&&(w.slice(-1)!="%")){ |
||
662 | w=parseInt(w,10)+"px"; |
||
663 | } |
||
664 | return w;
|
||
665 | }; |
||
666 | if(!_44.structure&&_45.nodeName.toLowerCase()=="table"){ |
||
667 | _44.structure=d.query("> colgroup",_45).map(function(cg){ |
||
668 | var sv=d.attr(cg,"span"); |
||
669 | var v={noscroll:(d.attr(cg,"noscroll")=="true")?true:false,__span:(!!sv?parseInt(sv,10):1),cells:[]}; |
||
670 | if(d.hasAttr(cg,"width")){ |
||
671 | v.width=_48(cg); |
||
672 | } |
||
673 | return v;
|
||
674 | }); |
||
675 | if(!_44.structure.length){
|
||
676 | _44.structure.push({__span:Infinity,cells:[]}); |
||
677 | } |
||
678 | d.query("thead > tr",_45).forEach(function(tr,_49){ |
||
679 | var _4a=0; |
||
680 | var _4b=0; |
||
681 | var _4c;
|
||
682 | var _4d=null; |
||
683 | d.query("> th",tr).map(function(th){ |
||
684 | if(!_4d){
|
||
685 | _4c=0;
|
||
686 | _4d=_44.structure[0];
|
||
687 | }else{
|
||
688 | if(_4a>=(_4c+_4d.__span)){
|
||
689 | _4b++; |
||
690 | _4c+=_4d.__span; |
||
691 | var _4e=_4d;
|
||
692 | _4d=_44.structure[_4b]; |
||
693 | } |
||
694 | } |
||
695 | var _4f={name:d.trim(d.attr(th,"name")||th.innerHTML),colSpan:parseInt(d.attr(th,"colspan")||1,10),type:d.trim(d.attr(th,"cellType")||""),id:d.trim(d.attr(th,"id")||"")}; |
||
696 | _4a+=_4f.colSpan; |
||
697 | var _50=d.attr(th,"rowspan"); |
||
698 | if(_50){
|
||
699 | _4f.rowSpan=_50; |
||
700 | } |
||
701 | if(d.hasAttr(th,"width")){ |
||
702 | _4f.width=_48(th); |
||
703 | } |
||
704 | if(d.hasAttr(th,"relWidth")){ |
||
705 | _4f.relWidth=window.parseInt(dojo.attr(th,"relWidth"),10); |
||
706 | } |
||
707 | if(d.hasAttr(th,"hidden")){ |
||
708 | _4f.hidden=d.attr(th,"hidden")=="true"; |
||
709 | } |
||
710 | if(_47){
|
||
711 | _47(th,_4f); |
||
712 | } |
||
713 | _4f.type=_4f.type?dojo.getObject(_4f.type):dojox.grid.cells.Cell; |
||
714 | if(_4f.type&&_4f.type.markupFactory){
|
||
715 | _4f.type.markupFactory(th,_4f); |
||
716 | } |
||
717 | if(!_4d.cells[_49]){
|
||
718 | _4d.cells[_49]=[]; |
||
719 | } |
||
720 | _4d.cells[_49].push(_4f); |
||
721 | }); |
||
722 | }); |
||
723 | } |
||
724 | return new _46(_44,_45); |
||
725 | }; |
||
726 | })(); |
||
727 | } |