| 1 |
define([ |
| 2 |
"dojo/_base/kernel", |
| 3 |
"../main", |
| 4 |
"dojo/_base/declare", |
| 5 |
"./_Events", |
| 6 |
"./_Scroller", |
| 7 |
"./_Layout", |
| 8 |
"./_View", |
| 9 |
"./_ViewManager", |
| 10 |
"./_RowManager", |
| 11 |
"./_FocusManager", |
| 12 |
"./_EditManager", |
| 13 |
"./Selection", |
| 14 |
"./_RowSelector", |
| 15 |
"./util", |
| 16 |
"dijit/_Widget", |
| 17 |
"dijit/_TemplatedMixin", |
| 18 |
"dijit/CheckedMenuItem", |
| 19 |
"dojo/text!./resources/_Grid.html", |
| 20 |
"dojo/string", |
| 21 |
"dojo/_base/array", |
| 22 |
"dojo/_base/lang", |
| 23 |
"dojo/_base/sniff", |
| 24 |
"dojox/html/metrics", |
| 25 |
"dojo/_base/html", |
| 26 |
"dojo/query", |
| 27 |
"dojo/dnd/common", |
| 28 |
"dojo/i18n!dijit/nls/loading" |
| 29 |
], function(dojo, dojox, declare, _Events, _Scroller, _Layout, _View, _ViewManager, |
| 30 |
_RowManager, _FocusManager, _EditManager, Selection, _RowSelector, util, _Widget, |
| 31 |
_TemplatedMixin, CheckedMenuItem, template, string, array, lang, has, metrics, html, query){ |
| 32 |
|
| 33 |
|
| 34 |
if(!dojo.isCopyKey){ |
| 35 |
dojo.isCopyKey = dojo.dnd.getCopyKeyState; |
| 36 |
} |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
var _Grid = declare('dojox.grid._Grid', |
| 131 |
[ _Widget, _TemplatedMixin, _Events ], |
| 132 |
{ |
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
templateString: template, |
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
classTag: 'dojoxGrid', |
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
rowCount: 5, |
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
keepRows: 75, |
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
rowsPerPage: 25, |
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
autoWidth: false, |
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
initialWidth: "", |
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
autoHeight: '', |
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
rowHeight: 0, |
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
autoRender: true, |
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
defaultHeight: '15em', |
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
height: '', |
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
structure: null, |
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
elasticView: -1, |
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
singleClickEdit: false, |
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
selectionMode: 'extended', |
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
rowSelector: '', |
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
columnReordering: false, |
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
headerMenu: null, |
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
placeholderLabel: "GridColumns", |
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
selectable: false, |
| 266 |
|
| 267 |
|
| 268 |
_click: null, |
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
loadingMessage: "<span class='dojoxGridLoading'>${loadingState}</span>", |
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
errorMessage: "<span class='dojoxGridError'>${errorState}</span>", |
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
noDataMessage: "", |
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
escapeHTMLInData: true, |
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
formatterScope: null, |
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
editable: false, |
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
summary: '', |
| 309 |
_setSummaryAttr: 'domNode', |
| 310 |
|
| 311 |
|
| 312 |
sortInfo: 0, |
| 313 |
|
| 314 |
|
| 315 |
_placeholders: null, |
| 316 |
|
| 317 |
|
| 318 |
|
| 319 |
_layoutClass: _Layout, |
| 320 |
|
| 321 |
|
| 322 |
buildRendering: function(){ |
| 323 |
this.inherited(arguments); |
| 324 |
if(!this.domNode.getAttribute('tabIndex')){ |
| 325 |
this.domNode.tabIndex = "0"; |
| 326 |
} |
| 327 |
this.createScroller(); |
| 328 |
this.createLayout(); |
| 329 |
this.createViews(); |
| 330 |
this.createManagers(); |
| 331 |
|
| 332 |
this.createSelection(); |
| 333 |
|
| 334 |
this.connect(this.selection, "onSelected", "onSelected"); |
| 335 |
this.connect(this.selection, "onDeselected", "onDeselected"); |
| 336 |
this.connect(this.selection, "onChanged", "onSelectionChanged"); |
| 337 |
|
| 338 |
metrics.initOnFontResize(); |
| 339 |
this.connect(metrics, "onFontResize", "textSizeChanged"); |
| 340 |
util.funnelEvents(this.domNode, this, 'doKeyEvent', util.keyEvents); |
| 341 |
if (this.selectionMode != "none") { |
| 342 |
this.domNode.setAttribute("aria-multiselectable", this.selectionMode == "single" ? "false" : "true"); |
| 343 |
} |
| 344 |
|
| 345 |
html.addClass(this.domNode, this.classTag); |
| 346 |
if(!this.isLeftToRight()){ |
| 347 |
html.addClass(this.domNode, this.classTag+"Rtl"); |
| 348 |
} |
| 349 |
if(this.rowHeight > 0){ |
| 350 |
html.addClass(this.viewsNode, this.classTag + "FixedRowHeight"); |
| 351 |
} |
| 352 |
}, |
| 353 |
|
| 354 |
postMixInProperties: function(){ |
| 355 |
this.inherited(arguments); |
| 356 |
var messages = dojo.i18n.getLocalization("dijit", "loading", this.lang); |
| 357 |
this.loadingMessage = string.substitute(this.loadingMessage, messages); |
| 358 |
this.errorMessage = string.substitute(this.errorMessage, messages); |
| 359 |
if(this.srcNodeRef && this.srcNodeRef.style.height){ |
| 360 |
this.height = this.srcNodeRef.style.height; |
| 361 |
} |
| 362 |
|
| 363 |
this._setAutoHeightAttr(this.autoHeight, true); |
| 364 |
this.lastScrollTop = this.scrollTop = 0; |
| 365 |
}, |
| 366 |
|
| 367 |
postCreate: function(){ |
| 368 |
this._placeholders = []; |
| 369 |
this._setHeaderMenuAttr(this.headerMenu); |
| 370 |
this._setStructureAttr(this.structure); |
| 371 |
this._click = []; |
| 372 |
this.inherited(arguments); |
| 373 |
if(this.domNode && this.autoWidth && this.initialWidth){ |
| 374 |
this.domNode.style.width = this.initialWidth; |
| 375 |
} |
| 376 |
if (this.domNode && !this.editable){ |
| 377 |
|
| 378 |
html.attr(this.domNode,"aria-readonly", "true"); |
| 379 |
} |
| 380 |
}, |
| 381 |
|
| 382 |
destroy: function(){ |
| 383 |
this.domNode.onReveal = null; |
| 384 |
this.domNode.onSizeChange = null; |
| 385 |
|
| 386 |
|
| 387 |
delete this._click; |
| 388 |
|
| 389 |
if(this.scroller){ |
| 390 |
this.scroller.destroy(); |
| 391 |
delete this.scroller; |
| 392 |
} |
| 393 |
this.edit.destroy(); |
| 394 |
delete this.edit; |
| 395 |
this.views.destroyViews(); |
| 396 |
if(this.focus){ |
| 397 |
this.focus.destroy(); |
| 398 |
delete this.focus; |
| 399 |
} |
| 400 |
if(this.headerMenu&&this._placeholders.length){ |
| 401 |
array.forEach(this._placeholders, function(p){ p.unReplace(true); }); |
| 402 |
this.headerMenu.unBindDomNode(this.viewsHeaderNode); |
| 403 |
} |
| 404 |
this.inherited(arguments); |
| 405 |
}, |
| 406 |
|
| 407 |
_setAutoHeightAttr: function(ah, skipRender){ |
| 408 |
|
| 409 |
if(typeof ah == "string"){ |
| 410 |
if(!ah || ah == "false"){ |
| 411 |
ah = false; |
| 412 |
}else if (ah == "true"){ |
| 413 |
ah = true; |
| 414 |
}else{ |
| 415 |
ah = window.parseInt(ah, 10); |
| 416 |
} |
| 417 |
} |
| 418 |
if(typeof ah == "number"){ |
| 419 |
if(isNaN(ah)){ |
| 420 |
ah = false; |
| 421 |
} |
| 422 |
|
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
if(ah < 0){ |
| 427 |
ah = true; |
| 428 |
}else if (ah === 0){ |
| 429 |
ah = false; |
| 430 |
} |
| 431 |
} |
| 432 |
this.autoHeight = ah; |
| 433 |
if(typeof ah == "boolean"){ |
| 434 |
this._autoHeight = ah; |
| 435 |
}else if(typeof ah == "number"){ |
| 436 |
this._autoHeight = (ah >= this.get('rowCount')); |
| 437 |
}else{ |
| 438 |
this._autoHeight = false; |
| 439 |
} |
| 440 |
if(this._started && !skipRender){ |
| 441 |
this.render(); |
| 442 |
} |
| 443 |
}, |
| 444 |
|
| 445 |
_getRowCountAttr: function(){ |
| 446 |
return this.updating && this.invalidated && this.invalidated.rowCount != undefined ? |
| 447 |
this.invalidated.rowCount : this.rowCount; |
| 448 |
}, |
| 449 |
|
| 450 |
textSizeChanged: function(){ |
| 451 |
this.render(); |
| 452 |
}, |
| 453 |
|
| 454 |
sizeChange: function(){ |
| 455 |
this.update(); |
| 456 |
}, |
| 457 |
|
| 458 |
createManagers: function(){ |
| 459 |
|
| 460 |
|
| 461 |
|
| 462 |
|
| 463 |
this.rows = new _RowManager(this); |
| 464 |
|
| 465 |
this.focus = new _FocusManager(this); |
| 466 |
|
| 467 |
this.edit = new _EditManager(this); |
| 468 |
}, |
| 469 |
|
| 470 |
createSelection: function(){ |
| 471 |
|
| 472 |
|
| 473 |
|
| 474 |
this.selection = new Selection(this); |
| 475 |
}, |
| 476 |
|
| 477 |
createScroller: function(){ |
| 478 |
|
| 479 |
|
| 480 |
this.scroller = new _Scroller(); |
| 481 |
this.scroller.grid = this; |
| 482 |
this.scroller.renderRow = lang.hitch(this, "renderRow"); |
| 483 |
this.scroller.removeRow = lang.hitch(this, "rowRemoved"); |
| 484 |
}, |
| 485 |
|
| 486 |
createLayout: function(){ |
| 487 |
|
| 488 |
|
| 489 |
this.layout = new this._layoutClass(this); |
| 490 |
this.connect(this.layout, "moveColumn", "onMoveColumn"); |
| 491 |
}, |
| 492 |
|
| 493 |
onMoveColumn: function(){ |
| 494 |
this.update(); |
| 495 |
}, |
| 496 |
|
| 497 |
onResizeColumn: function( cellIdx){ |
| 498 |
|
| 499 |
}, |
| 500 |
|
| 501 |
|
| 502 |
createViews: function(){ |
| 503 |
this.views = new _ViewManager(this); |
| 504 |
this.views.createView = lang.hitch(this, "createView"); |
| 505 |
}, |
| 506 |
|
| 507 |
createView: function(inClass, idx){ |
| 508 |
var c = lang.getObject(inClass); |
| 509 |
var view = new c({ grid: this, index: idx }); |
| 510 |
this.viewsNode.appendChild(view.domNode); |
| 511 |
this.viewsHeaderNode.appendChild(view.headerNode); |
| 512 |
this.views.addView(view); |
| 513 |
html.attr(this.domNode, "align", this.isLeftToRight() ? 'left' : 'right'); |
| 514 |
return view; |
| 515 |
}, |
| 516 |
|
| 517 |
buildViews: function(){ |
| 518 |
for(var i=0, vs; (vs=this.layout.structure[i]); i++){ |
| 519 |
this.createView(vs.type || dojox._scopeName + ".grid._View", i).setStructure(vs); |
| 520 |
} |
| 521 |
this.scroller.setContentNodes(this.views.getContentNodes()); |
| 522 |
}, |
| 523 |
|
| 524 |
_setStructureAttr: function(structure){ |
| 525 |
var s = structure; |
| 526 |
if(s && lang.isString(s)){ |
| 527 |
dojo.deprecated("dojox.grid._Grid.set('structure', 'objVar')", "use dojox.grid._Grid.set('structure', objVar) instead", "2.0"); |
| 528 |
s=lang.getObject(s); |
| 529 |
} |
| 530 |
this.structure = s; |
| 531 |
if(!s){ |
| 532 |
if(this.layout.structure){ |
| 533 |
s = this.layout.structure; |
| 534 |
}else{ |
| 535 |
return; |
| 536 |
} |
| 537 |
} |
| 538 |
this.views.destroyViews(); |
| 539 |
this.focus.focusView = null; |
| 540 |
if(s !== this.layout.structure){ |
| 541 |
this.layout.setStructure(s); |
| 542 |
} |
| 543 |
this._structureChanged(); |
| 544 |
}, |
| 545 |
|
| 546 |
setStructure: function( inStructure){ |
| 547 |
|
| 548 |
|
| 549 |
dojo.deprecated("dojox.grid._Grid.setStructure(obj)", "use dojox.grid._Grid.set('structure', obj) instead.", "2.0"); |
| 550 |
this._setStructureAttr(inStructure); |
| 551 |
}, |
| 552 |
|
| 553 |
getColumnTogglingItems: function(){ |
| 554 |
|
| 555 |
|
| 556 |
|
| 557 |
var items, checkedItems = []; |
| 558 |
items = array.map(this.layout.cells, function(cell){ |
| 559 |
if(!cell.menuItems){ cell.menuItems = []; } |
| 560 |
|
| 561 |
var self = this; |
| 562 |
var item = new CheckedMenuItem({ |
| 563 |
label: cell.name, |
| 564 |
checked: !cell.hidden, |
| 565 |
_gridCell: cell, |
| 566 |
onChange: function(checked){ |
| 567 |
if(self.layout.setColumnVisibility(this._gridCell.index, checked)){ |
| 568 |
var items = this._gridCell.menuItems; |
| 569 |
if(items.length > 1){ |
| 570 |
array.forEach(items, function(item){ |
| 571 |
if(item !== this){ |
| 572 |
item.setAttribute("checked", checked); |
| 573 |
} |
| 574 |
}, this); |
| 575 |
} |
| 576 |
checked = array.filter(self.layout.cells, function(c){ |
| 577 |
if(c.menuItems.length > 1){ |
| 578 |
array.forEach(c.menuItems, "item.set('disabled', false);"); |
| 579 |
}else{ |
| 580 |
c.menuItems[0].set('disabled', false); |
| 581 |
} |
| 582 |
return !c.hidden; |
| 583 |
}); |
| 584 |
if(checked.length == 1){ |
| 585 |
array.forEach(checked[0].menuItems, "item.set('disabled', true);"); |
| 586 |
} |
| 587 |
} |
| 588 |
}, |
| 589 |
destroy: function(){ |
| 590 |
var index = array.indexOf(this._gridCell.menuItems, this); |
| 591 |
this._gridCell.menuItems.splice(index, 1); |
| 592 |
delete this._gridCell; |
| 593 |
CheckedMenuItem.prototype.destroy.apply(this, arguments); |
| 594 |
} |
| 595 |
}); |
| 596 |
cell.menuItems.push(item); |
| 597 |
if(!cell.hidden) { |
| 598 |
checkedItems.push(item); |
| 599 |
} |
| 600 |
return item; |
| 601 |
}, this); |
| 602 |
if(checkedItems.length == 1) { |
| 603 |
checkedItems[0].set('disabled', true); |
| 604 |
} |
| 605 |
return items; |
| 606 |
}, |
| 607 |
|
| 608 |
_setHeaderMenuAttr: function(menu){ |
| 609 |
if(this._placeholders && this._placeholders.length){ |
| 610 |
array.forEach(this._placeholders, function(p){ |
| 611 |
p.unReplace(true); |
| 612 |
}); |
| 613 |
this._placeholders = []; |
| 614 |
} |
| 615 |
if(this.headerMenu){ |
| 616 |
this.headerMenu.unBindDomNode(this.viewsHeaderNode); |
| 617 |
} |
| 618 |
this.headerMenu = menu; |
| 619 |
if(!menu){ return; } |
| 620 |
|
| 621 |
this.headerMenu.bindDomNode(this.viewsHeaderNode); |
| 622 |
if(this.headerMenu.getPlaceholders){ |
| 623 |
this._placeholders = this.headerMenu.getPlaceholders(this.placeholderLabel); |
| 624 |
} |
| 625 |
}, |
| 626 |
|
| 627 |
setHeaderMenu: function( menu){ |
| 628 |
dojo.deprecated("dojox.grid._Grid.setHeaderMenu(obj)", "use dojox.grid._Grid.set('headerMenu', obj) instead.", "2.0"); |
| 629 |
this._setHeaderMenuAttr(menu); |
| 630 |
}, |
| 631 |
|
| 632 |
setupHeaderMenu: function(){ |
| 633 |
if(this._placeholders && this._placeholders.length){ |
| 634 |
array.forEach(this._placeholders, function(p){ |
| 635 |
if(p._replaced){ |
| 636 |
p.unReplace(true); |
| 637 |
} |
| 638 |
p.replace(this.getColumnTogglingItems()); |
| 639 |
}, this); |
| 640 |
} |
| 641 |
}, |
| 642 |
|
| 643 |
_fetch: function(start){ |
| 644 |
this.setScrollTop(0); |
| 645 |
}, |
| 646 |
|
| 647 |
getItem: function(inRowIndex){ |
| 648 |
return null; |
| 649 |
}, |
| 650 |
|
| 651 |
showMessage: function(message){ |
| 652 |
if(message){ |
| 653 |
this.messagesNode.innerHTML = message; |
| 654 |
this.messagesNode.style.display = ""; |
| 655 |
}else{ |
| 656 |
this.messagesNode.innerHTML = ""; |
| 657 |
this.messagesNode.style.display = "none"; |
| 658 |
} |
| 659 |
}, |
| 660 |
|
| 661 |
_structureChanged: function() { |
| 662 |
this.buildViews(); |
| 663 |
if(this.autoRender && this._started){ |
| 664 |
this.render(); |
| 665 |
} |
| 666 |
}, |
| 667 |
|
| 668 |
hasLayout: function() { |
| 669 |
return this.layout.cells.length; |
| 670 |
}, |
| 671 |
|
| 672 |
|
| 673 |
resize: function(changeSize, resultSize){ |
| 674 |
|
| 675 |
|
| 676 |
|
| 677 |
|
| 678 |
|
| 679 |
|
| 680 |
|
| 681 |
|
| 682 |
this._pendingChangeSize = changeSize; |
| 683 |
this._pendingResultSize = resultSize; |
| 684 |
this.sizeChange(); |
| 685 |
}, |
| 686 |
|
| 687 |
_getPadBorder: function() { |
| 688 |
this._padBorder = this._padBorder || html._getPadBorderExtents(this.domNode); |
| 689 |
return this._padBorder; |
| 690 |
}, |
| 691 |
|
| 692 |
_getHeaderHeight: function(){ |
| 693 |
var vns = this.viewsHeaderNode.style, t = vns.display == "none" ? 0 : this.views.measureHeader(); |
| 694 |
vns.height = t + 'px'; |
| 695 |
|
| 696 |
this.views.normalizeHeaderNodeHeight(); |
| 697 |
return t; |
| 698 |
}, |
| 699 |
|
| 700 |
_resize: function(changeSize, resultSize){ |
| 701 |
|
| 702 |
changeSize = changeSize || this._pendingChangeSize; |
| 703 |
resultSize = resultSize || this._pendingResultSize; |
| 704 |
delete this._pendingChangeSize; |
| 705 |
delete this._pendingResultSize; |
| 706 |
|
| 707 |
if(!this.domNode){ return; } |
| 708 |
var pn = this.domNode.parentNode; |
| 709 |
if(!pn || pn.nodeType != 1 || !this.hasLayout() || pn.style.visibility == "hidden" || pn.style.display == "none"){ |
| 710 |
return; |
| 711 |
} |
| 712 |
|
| 713 |
var padBorder = this._getPadBorder(); |
| 714 |
var hh = undefined; |
| 715 |
var h; |
| 716 |
|
| 717 |
if(this._autoHeight){ |
| 718 |
this.domNode.style.height = 'auto'; |
| 719 |
}else if(typeof this.autoHeight == "number"){ |
| 720 |
h = hh = this._getHeaderHeight(); |
| 721 |
h += (this.scroller.averageRowHeight * this.autoHeight); |
| 722 |
this.domNode.style.height = h + "px"; |
| 723 |
}else if(this.domNode.clientHeight <= padBorder.h){ |
| 724 |
if(pn == document.body){ |
| 725 |
this.domNode.style.height = this.defaultHeight; |
| 726 |
}else if(this.height){ |
| 727 |
this.domNode.style.height = this.height; |
| 728 |
}else{ |
| 729 |
this.fitTo = "parent"; |
| 730 |
} |
| 731 |
} |
| 732 |
|
| 733 |
if(resultSize){ |
| 734 |
changeSize = resultSize; |
| 735 |
} |
| 736 |
if(!this._autoHeight && changeSize){ |
| 737 |
html.marginBox(this.domNode, changeSize); |
| 738 |
this.height = this.domNode.style.height; |
| 739 |
delete this.fitTo; |
| 740 |
}else if(this.fitTo == "parent"){ |
| 741 |
h = this._parentContentBoxHeight = (this._parentContentBoxHeight > 0 ? this._parentContentBoxHeight : html._getContentBox(pn).h); |
| 742 |
this.domNode.style.height = Math.max(0, h) + "px"; |
| 743 |
} |
| 744 |
|
| 745 |
var hasFlex = array.some(this.views.views, function(v){ return v.flexCells; }); |
| 746 |
|
| 747 |
if(!this._autoHeight && (h || html._getContentBox(this.domNode).h) === 0){ |
| 748 |
|
| 749 |
this.viewsHeaderNode.style.display = "none"; |
| 750 |
}else{ |
| 751 |
|
| 752 |
this.viewsHeaderNode.style.display = "block"; |
| 753 |
if(!hasFlex && hh === undefined){ |
| 754 |
hh = this._getHeaderHeight(); |
| 755 |
} |
| 756 |
} |
| 757 |
if(hasFlex){ |
| 758 |
hh = undefined; |
| 759 |
} |
| 760 |
|
| 761 |
|
| 762 |
|
| 763 |
|
| 764 |
|
| 765 |
|
| 766 |
this.adaptWidth(); |
| 767 |
this.adaptHeight(hh); |
| 768 |
|
| 769 |
this.postresize(); |
| 770 |
}, |
| 771 |
|
| 772 |
adaptWidth: function() { |
| 773 |
|
| 774 |
|
| 775 |
|
| 776 |
|
| 777 |
var doAutoWidth = (!this.initialWidth && this.autoWidth); |
| 778 |
var w = doAutoWidth ? 0 : this.domNode.clientWidth || (this.domNode.offsetWidth - this._getPadBorder().w), |
| 779 |
vw = this.views.arrange(1, w); |
| 780 |
this.views.onEach("adaptWidth"); |
| 781 |
if(doAutoWidth){ |
| 782 |
this.domNode.style.width = vw + "px"; |
| 783 |
} |
| 784 |
}, |
| 785 |
|
| 786 |
adaptHeight: function(inHeaderHeight){ |
| 787 |
|
| 788 |
|
| 789 |
|
| 790 |
|
| 791 |
|
| 792 |
var t = inHeaderHeight === undefined ? this._getHeaderHeight() : inHeaderHeight; |
| 793 |
var h = (this._autoHeight ? -1 : Math.max(this.domNode.clientHeight - t, 0) || 0); |
| 794 |
this.views.onEach('setSize', [0, h]); |
| 795 |
this.views.onEach('adaptHeight'); |
| 796 |
if(!this._autoHeight){ |
| 797 |
var numScroll = 0, numNoScroll = 0; |
| 798 |
var noScrolls = array.filter(this.views.views, function(v){ |
| 799 |
var has = v.hasHScrollbar(); |
| 800 |
if(has){ numScroll++; }else{ numNoScroll++; } |
| 801 |
return (!has); |
| 802 |
}); |
| 803 |
if(numScroll > 0 && numNoScroll > 0){ |
| 804 |
array.forEach(noScrolls, function(v){ |
| 805 |
v.adaptHeight(true); |
| 806 |
}); |
| 807 |
} |
| 808 |
} |
| 809 |
if(this.autoHeight === true || h != -1 || (typeof this.autoHeight == "number" && this.autoHeight >= this.get('rowCount'))){ |
| 810 |
this.scroller.windowHeight = h; |
| 811 |
}else{ |
| 812 |
this.scroller.windowHeight = Math.max(this.domNode.clientHeight - t, 0); |
| 813 |
} |
| 814 |
}, |
| 815 |
|
| 816 |
|
| 817 |
startup: function(){ |
| 818 |
if(this._started){return;} |
| 819 |
this.inherited(arguments); |
| 820 |
if(this.autoRender){ |
| 821 |
this.render(); |
| 822 |
} |
| 823 |
}, |
| 824 |
|
| 825 |
|
| 826 |
render: function(){ |
| 827 |
|
| 828 |
|
| 829 |
|
| 830 |
|
| 831 |
if(!this.domNode){return;} |
| 832 |
if(!this._started){return;} |
| 833 |
|
| 834 |
if(!this.hasLayout()) { |
| 835 |
this.scroller.init(0, this.keepRows, this.rowsPerPage); |
| 836 |
return; |
| 837 |
} |
| 838 |
|
| 839 |
this.update = this.defaultUpdate; |
| 840 |
this._render(); |
| 841 |
}, |
| 842 |
|
| 843 |
_render: function(){ |
| 844 |
this.scroller.init(this.get('rowCount'), this.keepRows, this.rowsPerPage); |
| 845 |
this.prerender(); |
| 846 |
this.setScrollTop(0); |
| 847 |
this.postrender(); |
| 848 |
}, |
| 849 |
|
| 850 |
prerender: function(){ |
| 851 |
|
| 852 |
this.keepRows = this._autoHeight ? 0 : this.keepRows; |
| 853 |
this.scroller.setKeepInfo(this.keepRows); |
| 854 |
this.views.render(); |
| 855 |
this._resize(); |
| 856 |
}, |
| 857 |
|
| 858 |
postrender: function(){ |
| 859 |
this.postresize(); |
| 860 |
this.focus.initFocusView(); |
| 861 |
|
| 862 |
html.setSelectable(this.domNode, this.selectable); |
| 863 |
}, |
| 864 |
|
| 865 |
postresize: function(){ |
| 866 |
|
| 867 |
if(this._autoHeight){ |
| 868 |
var size = Math.max(this.views.measureContent()) + 'px'; |
| 869 |
|
| 870 |
this.viewsNode.style.height = size; |
| 871 |
} |
| 872 |
}, |
| 873 |
|
| 874 |
renderRow: function(inRowIndex, inNodes){ |
| 875 |
|
| 876 |
|
| 877 |
|
| 878 |
|
| 879 |
this.views.renderRow(inRowIndex, inNodes, this._skipRowRenormalize); |
| 880 |
}, |
| 881 |
|
| 882 |
rowRemoved: function(inRowIndex){ |
| 883 |
|
| 884 |
|
| 885 |
|
| 886 |
|
| 887 |
this.views.rowRemoved(inRowIndex); |
| 888 |
}, |
| 889 |
|
| 890 |
invalidated: null, |
| 891 |
|
| 892 |
updating: false, |
| 893 |
|
| 894 |
beginUpdate: function(){ |
| 895 |
|
| 896 |
|
| 897 |
|
| 898 |
this.invalidated = []; |
| 899 |
this.updating = true; |
| 900 |
}, |
| 901 |
|
| 902 |
endUpdate: function(){ |
| 903 |
|
| 904 |
|
| 905 |
this.updating = false; |
| 906 |
var i = this.invalidated, r; |
| 907 |
if(i.all){ |
| 908 |
this.update(); |
| 909 |
}else if(i.rowCount != undefined){ |
| 910 |
this.updateRowCount(i.rowCount); |
| 911 |
}else{ |
| 912 |
for(r in i){ |
| 913 |
this.updateRow(Number(r)); |
| 914 |
} |
| 915 |
} |
| 916 |
this.invalidated = []; |
| 917 |
}, |
| 918 |
|
| 919 |
|
| 920 |
defaultUpdate: function(){ |
| 921 |
|
| 922 |
if(!this.domNode){return;} |
| 923 |
if(this.updating){ |
| 924 |
this.invalidated.all = true; |
| 925 |
return; |
| 926 |
} |
| 927 |
|
| 928 |
this.lastScrollTop = this.scrollTop; |
| 929 |
this.prerender(); |
| 930 |
this.scroller.invalidateNodes(); |
| 931 |
this.setScrollTop(this.lastScrollTop); |
| 932 |
this.postrender(); |
| 933 |
|
| 934 |
}, |
| 935 |
|
| 936 |
update: function(){ |
| 937 |
|
| 938 |
|
| 939 |
this.render(); |
| 940 |
}, |
| 941 |
|
| 942 |
updateRow: function(inRowIndex){ |
| 943 |
|
| 944 |
|
| 945 |
|
| 946 |
|
| 947 |
inRowIndex = Number(inRowIndex); |
| 948 |
if(this.updating){ |
| 949 |
this.invalidated[inRowIndex]=true; |
| 950 |
}else{ |
| 951 |
this.views.updateRow(inRowIndex); |
| 952 |
this.scroller.rowHeightChanged(inRowIndex); |
| 953 |
} |
| 954 |
}, |
| 955 |
|
| 956 |
updateRows: function(startIndex, howMany){ |
| 957 |
|
| 958 |
|
| 959 |
|
| 960 |
|
| 961 |
|
| 962 |
|
| 963 |
startIndex = Number(startIndex); |
| 964 |
howMany = Number(howMany); |
| 965 |
var i; |
| 966 |
if(this.updating){ |
| 967 |
for(i=0; i<howMany; i++){ |
| 968 |
this.invalidated[i+startIndex]=true; |
| 969 |
} |
| 970 |
}else{ |
| 971 |
for(i=0; i<howMany; i++){ |
| 972 |
this.views.updateRow(i+startIndex, this._skipRowRenormalize); |
| 973 |
} |
| 974 |
this.scroller.rowHeightChanged(startIndex); |
| 975 |
} |
| 976 |
}, |
| 977 |
|
| 978 |
updateRowCount: function(inRowCount){ |
| 979 |
|
| 980 |
|
| 981 |
|
| 982 |
|
| 983 |
if(this.updating){ |
| 984 |
this.invalidated.rowCount = inRowCount; |
| 985 |
}else{ |
| 986 |
this.rowCount = inRowCount; |
| 987 |
this._setAutoHeightAttr(this.autoHeight, true); |
| 988 |
if(this.layout.cells.length){ |
| 989 |
this.scroller.updateRowCount(inRowCount); |
| 990 |
} |
| 991 |
if(this.layout.cells.length){ |
| 992 |
this.setScrollTop(this.scrollTop); |
| 993 |
} |
| 994 |
this._resize(); |
| 995 |
} |
| 996 |
}, |
| 997 |
|
| 998 |
updateRowStyles: function(inRowIndex){ |
| 999 |
|
| 1000 |
|
| 1001 |
this.views.updateRowStyles(inRowIndex); |
| 1002 |
}, |
| 1003 |
getRowNode: function(inRowIndex){ |
| 1004 |
|
| 1005 |
|
| 1006 |
if (this.focus.focusView && !(this.focus.focusView instanceof _RowSelector)){ |
| 1007 |
return this.focus.focusView.rowNodes[inRowIndex]; |
| 1008 |
}else{ |
| 1009 |
for (var i = 0, cView; (cView = this.views.views[i]); i++) { |
| 1010 |
if (!(cView instanceof _RowSelector)) { |
| 1011 |
return cView.rowNodes[inRowIndex]; |
| 1012 |
} |
| 1013 |
} |
| 1014 |
} |
| 1015 |
return null; |
| 1016 |
}, |
| 1017 |
rowHeightChanged: function(inRowIndex){ |
| 1018 |
|
| 1019 |
|
| 1020 |
|
| 1021 |
|
| 1022 |
|
| 1023 |
|
| 1024 |
this.views.renormalizeRow(inRowIndex); |
| 1025 |
this.scroller.rowHeightChanged(inRowIndex); |
| 1026 |
}, |
| 1027 |
|
| 1028 |
|
| 1029 |
|
| 1030 |
|
| 1031 |
fastScroll: true, |
| 1032 |
|
| 1033 |
delayScroll: false, |
| 1034 |
|
| 1035 |
|
| 1036 |
|
| 1037 |
scrollRedrawThreshold: (has('ie') ? 100 : 50), |
| 1038 |
|
| 1039 |
|
| 1040 |
scrollTo: function(inTop){ |
| 1041 |
|
| 1042 |
|
| 1043 |
|
| 1044 |
|
| 1045 |
if(!this.fastScroll){ |
| 1046 |
this.setScrollTop(inTop); |
| 1047 |
return; |
| 1048 |
} |
| 1049 |
var delta = Math.abs(this.lastScrollTop - inTop); |
| 1050 |
this.lastScrollTop = inTop; |
| 1051 |
if(delta > this.scrollRedrawThreshold || this.delayScroll){ |
| 1052 |
this.delayScroll = true; |
| 1053 |
this.scrollTop = inTop; |
| 1054 |
this.views.setScrollTop(inTop); |
| 1055 |
if(this._pendingScroll){ |
| 1056 |
window.clearTimeout(this._pendingScroll); |
| 1057 |
} |
| 1058 |
var _this = this; |
| 1059 |
this._pendingScroll = window.setTimeout(function(){ |
| 1060 |
delete _this._pendingScroll; |
| 1061 |
_this.finishScrollJob(); |
| 1062 |
}, 200); |
| 1063 |
}else{ |
| 1064 |
this.setScrollTop(inTop); |
| 1065 |
} |
| 1066 |
}, |
| 1067 |
|
| 1068 |
finishScrollJob: function(){ |
| 1069 |
this.delayScroll = false; |
| 1070 |
this.setScrollTop(this.scrollTop); |
| 1071 |
}, |
| 1072 |
|
| 1073 |
setScrollTop: function(inTop){ |
| 1074 |
this.scroller.scroll(this.views.setScrollTop(inTop)); |
| 1075 |
}, |
| 1076 |
|
| 1077 |
scrollToRow: function(inRowIndex){ |
| 1078 |
|
| 1079 |
|
| 1080 |
|
| 1081 |
|
| 1082 |
this.setScrollTop(this.scroller.findScrollTop(inRowIndex) + 1); |
| 1083 |
}, |
| 1084 |
|
| 1085 |
styleRowNode: function(inRowIndex, inRowNode){ |
| 1086 |
|
| 1087 |
|
| 1088 |
|
| 1089 |
|
| 1090 |
if(inRowNode){ |
| 1091 |
this.rows.styleRowNode(inRowIndex, inRowNode); |
| 1092 |
} |
| 1093 |
}, |
| 1094 |
|
| 1095 |
|
| 1096 |
_mouseOut: function(e){ |
| 1097 |
this.rows.setOverRow(-2); |
| 1098 |
}, |
| 1099 |
|
| 1100 |
|
| 1101 |
getCell: function(inIndex){ |
| 1102 |
|
| 1103 |
|
| 1104 |
|
| 1105 |
|
| 1106 |
|
| 1107 |
|
| 1108 |
return this.layout.cells[inIndex]; |
| 1109 |
}, |
| 1110 |
|
| 1111 |
setCellWidth: function(inIndex, inUnitWidth){ |
| 1112 |
this.getCell(inIndex).unitWidth = inUnitWidth; |
| 1113 |
}, |
| 1114 |
|
| 1115 |
getCellName: function(inCell){ |
| 1116 |
|
| 1117 |
|
| 1118 |
return "Cell " + inCell.index; |
| 1119 |
}, |
| 1120 |
|
| 1121 |
|
| 1122 |
canSort: function(inSortInfo){ |
| 1123 |
|
| 1124 |
|
| 1125 |
|
| 1126 |
|
| 1127 |
|
| 1128 |
|
| 1129 |
|
| 1130 |
}, |
| 1131 |
|
| 1132 |
sort: function(){ |
| 1133 |
}, |
| 1134 |
|
| 1135 |
getSortAsc: function(inSortInfo){ |
| 1136 |
|
| 1137 |
|
| 1138 |
inSortInfo = inSortInfo == undefined ? this.sortInfo : inSortInfo; |
| 1139 |
return Boolean(inSortInfo > 0); |
| 1140 |
}, |
| 1141 |
|
| 1142 |
getSortIndex: function(inSortInfo){ |
| 1143 |
|
| 1144 |
|
| 1145 |
inSortInfo = inSortInfo == undefined ? this.sortInfo : inSortInfo; |
| 1146 |
return Math.abs(inSortInfo) - 1; |
| 1147 |
}, |
| 1148 |
|
| 1149 |
setSortIndex: function(inIndex, inAsc){ |
| 1150 |
|
| 1151 |
|
| 1152 |
|
| 1153 |
|
| 1154 |
|
| 1155 |
|
| 1156 |
var si = inIndex +1; |
| 1157 |
if(inAsc != undefined){ |
| 1158 |
si *= (inAsc ? 1 : -1); |
| 1159 |
} else if(this.getSortIndex() == inIndex){ |
| 1160 |
si = -this.sortInfo; |
| 1161 |
} |
| 1162 |
this.setSortInfo(si); |
| 1163 |
}, |
| 1164 |
|
| 1165 |
setSortInfo: function(inSortInfo){ |
| 1166 |
if(this.canSort(inSortInfo)){ |
| 1167 |
this.sortInfo = inSortInfo; |
| 1168 |
this.sort(); |
| 1169 |
this.update(); |
| 1170 |
} |
| 1171 |
}, |
| 1172 |
|
| 1173 |
|
| 1174 |
doKeyEvent: function(e){ |
| 1175 |
e.dispatch = 'do' + e.type; |
| 1176 |
this.onKeyEvent(e); |
| 1177 |
}, |
| 1178 |
|
| 1179 |
|
| 1180 |
|
| 1181 |
_dispatch: function(m, e){ |
| 1182 |
if(m in this){ |
| 1183 |
return this[m](e); |
| 1184 |
} |
| 1185 |
return false; |
| 1186 |
}, |
| 1187 |
|
| 1188 |
dispatchKeyEvent: function(e){ |
| 1189 |
this._dispatch(e.dispatch, e); |
| 1190 |
}, |
| 1191 |
|
| 1192 |
dispatchContentEvent: function(e){ |
| 1193 |
this.edit.dispatchEvent(e) || e.sourceView.dispatchContentEvent(e) || this._dispatch(e.dispatch, e); |
| 1194 |
}, |
| 1195 |
|
| 1196 |
dispatchHeaderEvent: function(e){ |
| 1197 |
e.sourceView.dispatchHeaderEvent(e) || this._dispatch('doheader' + e.type, e); |
| 1198 |
}, |
| 1199 |
|
| 1200 |
dokeydown: function(e){ |
| 1201 |
this.onKeyDown(e); |
| 1202 |
}, |
| 1203 |
|
| 1204 |
doclick: function(e){ |
| 1205 |
if(e.cellNode){ |
| 1206 |
this.onCellClick(e); |
| 1207 |
}else{ |
| 1208 |
this.onRowClick(e); |
| 1209 |
} |
| 1210 |
}, |
| 1211 |
|
| 1212 |
dodblclick: function(e){ |
| 1213 |
if(e.cellNode){ |
| 1214 |
this.onCellDblClick(e); |
| 1215 |
}else{ |
| 1216 |
this.onRowDblClick(e); |
| 1217 |
} |
| 1218 |
}, |
| 1219 |
|
| 1220 |
docontextmenu: function(e){ |
| 1221 |
if(e.cellNode){ |
| 1222 |
this.onCellContextMenu(e); |
| 1223 |
}else{ |
| 1224 |
this.onRowContextMenu(e); |
| 1225 |
} |
| 1226 |
}, |
| 1227 |
|
| 1228 |
doheaderclick: function(e){ |
| 1229 |
if(e.cellNode){ |
| 1230 |
this.onHeaderCellClick(e); |
| 1231 |
}else{ |
| 1232 |
this.onHeaderClick(e); |
| 1233 |
} |
| 1234 |
}, |
| 1235 |
|
| 1236 |
doheaderdblclick: function(e){ |
| 1237 |
if(e.cellNode){ |
| 1238 |
this.onHeaderCellDblClick(e); |
| 1239 |
}else{ |
| 1240 |
this.onHeaderDblClick(e); |
| 1241 |
} |
| 1242 |
}, |
| 1243 |
|
| 1244 |
doheadercontextmenu: function(e){ |
| 1245 |
if(e.cellNode){ |
| 1246 |
this.onHeaderCellContextMenu(e); |
| 1247 |
}else{ |
| 1248 |
this.onHeaderContextMenu(e); |
| 1249 |
} |
| 1250 |
}, |
| 1251 |
|
| 1252 |
|
| 1253 |
doStartEdit: function(inCell, inRowIndex){ |
| 1254 |
this.onStartEdit(inCell, inRowIndex); |
| 1255 |
}, |
| 1256 |
|
| 1257 |
doApplyCellEdit: function(inValue, inRowIndex, inFieldIndex){ |
| 1258 |
this.onApplyCellEdit(inValue, inRowIndex, inFieldIndex); |
| 1259 |
}, |
| 1260 |
|
| 1261 |
doCancelEdit: function(inRowIndex){ |
| 1262 |
this.onCancelEdit(inRowIndex); |
| 1263 |
}, |
| 1264 |
|
| 1265 |
doApplyEdit: function(inRowIndex){ |
| 1266 |
this.onApplyEdit(inRowIndex); |
| 1267 |
}, |
| 1268 |
|
| 1269 |
|
| 1270 |
addRow: function(){ |
| 1271 |
|
| 1272 |
|
| 1273 |
this.updateRowCount(this.get('rowCount')+1); |
| 1274 |
}, |
| 1275 |
|
| 1276 |
removeSelectedRows: function(){ |
| 1277 |
|
| 1278 |
|
| 1279 |
if(this.allItemsSelected){ |
| 1280 |
this.updateRowCount(0); |
| 1281 |
}else{ |
| 1282 |
this.updateRowCount(Math.max(0, this.get('rowCount') - this.selection.getSelected().length)); |
| 1283 |
} |
| 1284 |
this.selection.clear(); |
| 1285 |
} |
| 1286 |
|
| 1287 |
}); |
| 1288 |
|
| 1289 |
_Grid.markupFactory = function(props, node, ctor, cellFunc){ |
| 1290 |
var widthFromAttr = function(n){ |
| 1291 |
var w = html.attr(n, "width")||"auto"; |
| 1292 |
if((w != "auto")&&(w.slice(-2) != "em")&&(w.slice(-1) != "%")){ |
| 1293 |
w = parseInt(w, 10)+"px"; |
| 1294 |
} |
| 1295 |
return w; |
| 1296 |
}; |
| 1297 |
|
| 1298 |
|
| 1299 |
|
| 1300 |
if( !props.structure && |
| 1301 |
node.nodeName.toLowerCase() == "table"){ |
| 1302 |
|
| 1303 |
|
| 1304 |
props.structure = query("> colgroup", node).map(function(cg){ |
| 1305 |
var sv = html.attr(cg, "span"); |
| 1306 |
var v = { |
| 1307 |
noscroll: (html.attr(cg, "noscroll") == "true") ? true : false, |
| 1308 |
__span: (!!sv ? parseInt(sv, 10) : 1), |
| 1309 |
cells: [] |
| 1310 |
}; |
| 1311 |
if(html.hasAttr(cg, "width")){ |
| 1312 |
v.width = widthFromAttr(cg); |
| 1313 |
} |
| 1314 |
return v; |
| 1315 |
}); |
| 1316 |
if(!props.structure.length){ |
| 1317 |
props.structure.push({ |
| 1318 |
__span: Infinity, |
| 1319 |
cells: [] |
| 1320 |
}); |
| 1321 |
} |
| 1322 |
|
| 1323 |
|
| 1324 |
|
| 1325 |
query("thead > tr", node).forEach(function(tr, tr_idx){ |
| 1326 |
var cellCount = 0; |
| 1327 |
var viewIdx = 0; |
| 1328 |
var lastViewIdx; |
| 1329 |
var cView = null; |
| 1330 |
query("> th", tr).map(function(th){ |
| 1331 |
|
| 1332 |
|
| 1333 |
|
| 1334 |
|
| 1335 |
|
| 1336 |
|
| 1337 |
|
| 1338 |
|
| 1339 |
|
| 1340 |
if(!cView){ |
| 1341 |
lastViewIdx = 0; |
| 1342 |
cView = props.structure[0]; |
| 1343 |
}else if(cellCount >= (lastViewIdx+cView.__span)){ |
| 1344 |
viewIdx++; |
| 1345 |
|
| 1346 |
lastViewIdx += cView.__span; |
| 1347 |
var lastView = cView; |
| 1348 |
cView = props.structure[viewIdx]; |
| 1349 |
} |
| 1350 |
|
| 1351 |
|
| 1352 |
var cell = { |
| 1353 |
name: lang.trim(html.attr(th, "name")||th.innerHTML), |
| 1354 |
colSpan: parseInt(html.attr(th, "colspan")||1, 10), |
| 1355 |
type: lang.trim(html.attr(th, "cellType")||""), |
| 1356 |
id: lang.trim(html.attr(th,"id")||"") |
| 1357 |
}; |
| 1358 |
cellCount += cell.colSpan; |
| 1359 |
var rowSpan = html.attr(th, "rowspan"); |
| 1360 |
if(rowSpan){ |
| 1361 |
cell.rowSpan = rowSpan; |
| 1362 |
} |
| 1363 |
if(html.hasAttr(th, "width")){ |
| 1364 |
cell.width = widthFromAttr(th); |
| 1365 |
} |
| 1366 |
if(html.hasAttr(th, "relWidth")){ |
| 1367 |
cell.relWidth = window.parseInt(html.attr(th, "relWidth"), 10); |
| 1368 |
} |
| 1369 |
if(html.hasAttr(th, "hidden")){ |
| 1370 |
cell.hidden = (html.attr(th, "hidden") == "true" || html.attr(th, "hidden") === true); |
| 1371 |
} |
| 1372 |
|
| 1373 |
if(cellFunc){ |
| 1374 |
cellFunc(th, cell); |
| 1375 |
} |
| 1376 |
|
| 1377 |
cell.type = cell.type ? lang.getObject(cell.type) : dojox.grid.cells.Cell; |
| 1378 |
|
| 1379 |
if(cell.type && cell.type.markupFactory){ |
| 1380 |
cell.type.markupFactory(th, cell); |
| 1381 |
} |
| 1382 |
|
| 1383 |
if(!cView.cells[tr_idx]){ |
| 1384 |
cView.cells[tr_idx] = []; |
| 1385 |
} |
| 1386 |
cView.cells[tr_idx].push(cell); |
| 1387 |
}); |
| 1388 |
}); |
| 1389 |
} |
| 1390 |
|
| 1391 |
return new ctor(props, node); |
| 1392 |
}; |
| 1393 |
|
| 1394 |
return _Grid; |
| 1395 |
|
| 1396 |
}); |