123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- /*******************************************************************************
- * IBM Confidential
- *
- * OCO Source Materials
- *
- * A and PM: PD
- *
- * (c) Copyright IBM Corp. 2014
- *
- * The source code for this program is not published or otherwise divested of
- * its trade secrets, irrespective of what has been deposited with the U.S.
- * Copyright Office.
- ******************************************************************************/
- define([
- "dojo/_base/declare",
- "dojox/grid/EnhancedGrid",
- "dojo/_base/array",
- "dojo/query",
- "dojo/dom-style",
- "dojo/dom-attr",
- "dojo/_base/html",
- "dijit/Tooltip",
- "dojox/grid/enhanced/plugins/Selector"
- ],function(declare, EnhancedGrid, array, query, domStyle, domAttr, html){
- var PreviewGrid = declare("pd/widgets/PreviewGrid", [EnhancedGrid], {
-
- rowsPerPage: 60,
- keepRows: 120,
- autoHeight: false,
-
- plugins: {
- selector: {
- col: "single",
- row: "single",
- cell: "disabled"
- }
- },
-
- constructor: function() {
- this.selector = null;
- },
-
- postMixInProperties: function(){
- this.structure = this.store.objectStore.pdGetOriginalStructure();
- this.inherited(arguments);
- },
-
- pdToggleColumns: function(selection){
- for (var i=0; i<selection.length; i++) {
- this.pdToggleColumn(selection[i], i==(selection.length-1));
- }
- },
-
- pdToggleColumn: function(sel, needResize) {
- if (sel.hidden){
- this.selector.deselect("col", sel.index);
- }
- this.layout.cells[sel.index].hidden = sel.hidden;
- query(".pd_idx"+sel.index, pd_previewContainer.domNode).
- style("display", sel.hidden?"none":"table-cell");
-
- if (needResize) {
- this.resize();
- if (!sel.hidden){
- this.pdSelectColumn(sel.index);
- }
- }
- },
-
- pdSelectColumn: function(idx) {
- //scroll to the column according to the selection from ColumnGrid.
- var prevColFocusIdx = this.focus._colHeadFocusIdx;
- var colHeaderNode = this.focus._findHeaderCells()[idx];
-
- this.selector.clear();
- this.selector.select("col", idx);
- this.scrollToRow(0);
-
- if (prevColFocusIdx != null && prevColFocusIdx >= 0 && prevColFocusIdx != idx){
- html.toggleClass(this.focus._findHeaderCells()[prevColFocusIdx],
- this.focus.focusClass, false);
- }
- html.toggleClass(colHeaderNode, this.focus.focusClass, true);
- this.focus._colHeadNode = colHeaderNode;
- this.focus._colHeadFocusIdx = idx;
- this.focus._scrollHeader(idx);
- },
-
- canSort: function(colIndex, field){
- // summary:
- // Overwritten
- return false;
- },
-
- textSizeChanged: function(){
- //override
- },
-
- startup: function() {
- this.inherited(arguments);
- this.connect(this, "onCellMouseOver", this._pdShowTooltip);
- this.connect(this, "onHeaderCellMouseOver", this._pdShowHeaderTooltip);
-
- this.selector = this.pluginMgr.getPlugin("selector");
- },
-
- _pdShowHeaderTooltip: function(e) {
- var structure = this.structure[0];
- var msg = structure[e.cellIndex].name;
-
- if (msg) {
- domAttr.set(e.cellNode, "title", msg);
- }
- },
-
- _pdShowTooltip: function(e) {
- var item = e.grid.getItem(e.rowIndex);
- var msg = e.grid.store.getValue(item, e.cell.field);
-
- if (msg) {
- domAttr.set(e.cellNode, "title", msg);
- }
- },
-
- defaultUpdate: function(){
- //override the default one, so the table doesn't get rerendered.
- if(!this.domNode){return;}
- if(this.updating){
- this.invalidated.all = true;
- return;
- }
- this.prerender();
- }
-
- });
-
- PreviewGrid.markupFactory = EnhancedGrid.markupFactory;
- PreviewGrid.registerPlugin = EnhancedGrid.registerPlugin;
-
- return PreviewGrid;
- });
|