dojox/grid/_Selector.js

  • Provides:

    • dojox.grid._Selector
  • Requires:

    • dojox.grid.Selection in common
    • dojox.grid._View in common
    • dojox.grid._Builder in common
  • dojox.grid._Selector

    • type
      Function
    • chains:
      • dojox.grid._View: (prototype)
      • dojox.grid._View: (call)
    • summary
      Custom grid view. If used in a grid structure, provides a small selectable region for grid rows.
  • dojox.grid._Selector.inputType

    • summary
  • dojox.grid._Selector.selectionMode

    • summary
  • dojox.grid._Selector.defaultWidth

    • summary
  • dojox.grid._Selector.noscroll

    • summary
  • dojox.grid._Selector.padBorderWidth

    • summary
  • dojox.grid._Selector._contentBuilderClass

    • summary
  • dojox.grid._Selector.postCreate

    • type
      Function
    • source: [view]
         this.connect(this.scrollboxNode,"onscroll","doscroll");
         dojox.grid.util.funnelEvents(this.contentNode, this, "doContentEvent", [ 'mouseover', 'mouseout', 'click', 'dblclick', 'contextmenu', 'mousedown' ]);
         dojox.grid.util.funnelEvents(this.headerNode, this, "doHeaderEvent", [ 'dblclick', 'mouseover', 'mouseout', 'mousemove', 'mousedown', 'click', 'contextmenu' ]);
         if(this._contentBuilderClass){
          this.content = new this._contentBuilderClass(this);
         }else{
          this.content = new dojox.grid._ContentBuilder(this);
         }
         if(this._headerBuilderClass){
          this.header = new this._headerBuilderClass(this);
         }else{
          this.header = new dojox.grid._HeaderBuilder(this);
         }
         //BiDi: in RTL case, style width='9000em' causes scrolling problem in head node
         if(!dojo._isBodyLtr()){
          this.headerNodeContainer.style.width = "";
         }
         this.connect(this.grid.selection, 'onSelected', 'onSelected');
         this.connect(this.grid.selection, 'onDeselected', 'onDeselected');
    • summary
  • dojox.grid._Selector.buildRendering

    • type
      Function
    • source: [view]
         this.inherited(arguments);
         this.scrollboxNode.style.overflow = "hidden";
    • summary
  • dojox.grid._Selector.getWidth

    • type
      Function
    • source: [view]
         return this.viewWidth || this.defaultWidth;
    • summary
  • dojox.grid._Selector.resize

    • type
      Function
    • source: [view]
         this.adaptHeight();
    • summary
  • dojox.grid._Selector.setStructure

    • type
      Function
    • parameters:
      • s: (typeof )
    • source: [view]
         this.inherited(arguments);
         if(s.defaultWidth){
          this.defaultWidth = s.defaultWidth;
         }
    • summary
  • dojox.grid._Selector.adaptWidth

    • type
      Function
    • source: [view]
      dojo.provide("dojox.grid._Selector");


      dojo.require("dojox.grid.Selection");
      dojo.require("dojox.grid._View");
      dojo.require("dojox.grid._Builder");


      (function(){
       dojox.grid._InputSelectorHeaderBuilder = dojo.extend(function(view){
        dojox.grid._HeaderBuilder.call(this, view);
       },dojox.grid._HeaderBuilder.prototype,{
        generateHtml: function(){
         var w = this.view.contentWidth || 0;
         var selectedCount = this.view.grid.selection.getSelectedCount();
         var checked = (selectedCount && selectedCount == this.view.grid.rowCount) ? ' dijitCheckBoxChecked dijitChecked' : '';
         return '    'border="0" cellspacing="0" cellpadding="0" ' +
          'role="presentation">
      ' +
          '
      ';
        },
        doclick: function(e){
         var selectedCount = this.view.grid.selection.getSelectedCount();


         this.view._selectionChanging = true;
         if(selectedCount==this.view.grid.rowCount){
          this.view.grid.selection.deselectAll();
         }else{
          this.view.grid.selection.selectRange(0, this.view.grid.rowCount-1);
         }
         this.view._selectionChanging = false;
         this.view.onSelectionChanged();
         return true;
        }
       });


       dojox.grid._SelectorContentBuilder = dojo.extend(function(view){
        dojox.grid._ContentBuilder.call(this, view);
       },dojox.grid._ContentBuilder.prototype,{
        generateHtml: function(inDataIndex, inRowIndex){
         var w = this.view.contentWidth || 0;
         return '    'cellspacing="0" cellpadding="0" role="presentation">' +
          '
      ' + this.getCellContent(inRowIndex) + '
      ';
        },
        getCellContent: function(inRowIndex){
         return ' ';
        },
        findTarget: function(){
         var t = dojox.grid._ContentBuilder.prototype.findTarget.apply(this, arguments);
         return t;
        },
        domouseover: function(e){
         this.view.grid.onMouseOverRow(e);
        },
        domouseout: function(e){
         if(!this.isIntraRowEvent(e)){
          this.view.grid.onMouseOutRow(e);
         }
        },
        doclick: function(e){
         var idx = e.rowIndex;
         var selected = this.view.grid.selection.isSelected(idx);
         var mode = this.view.grid.selection.mode;


         if(!selected){
          if(mode == 'single'){
           this.view.grid.selection.select(idx);
          }else if(mode != 'none'){
           this.view.grid.selection.addToSelection(idx);
          }
         }else{
          this.view.grid.selection.deselect(idx);
         }


         return true;
        }
       });


       dojox.grid._InputSelectorContentBuilder = dojo.extend(function(view){
        dojox.grid._SelectorContentBuilder.call(this, view);
       },dojox.grid._SelectorContentBuilder.prototype,{
        getCellContent: function(rowIndex){
         var v = this.view;
         var type = v.inputType == "checkbox" ? "CheckBox" : "Radio";
         var checked = !!v.grid.selection.isSelected(rowIndex) ? ' dijit' + type + 'Checked dijitChecked' : '';
         return '
      ';
        }
       });


       dojo.declare("dojox.grid._Selector", dojox.grid._View, {
        inputType: '',
        selectionMode: '',


        // summary:
        // Custom grid view. If used in a grid structure, provides a small selectable region for grid rows.
        defaultWidth: "2em",
        noscroll: true,
        padBorderWidth: 2,


        _contentBuilderClass: dojox.grid._SelectorContentBuilder,


        postCreate: function(){
         this.inherited(arguments);


         if(this.selectionMode){
          this.grid.selection.mode = this.selectionMode;
         }
         this.connect(this.grid.selection, 'onSelected', 'onSelected');
         this.connect(this.grid.selection, 'onDeselected', 'onDeselected');
        },
        buildRendering: function(){
         this.inherited(arguments);
         this.scrollboxNode.style.overflow = "hidden";
        },
        getWidth: function(){
         return this.viewWidth || this.defaultWidth;
        },
        resize: function(){
         this.adaptHeight();
        },
        setStructure: function(s){
         this.inherited(arguments);
         if(s.defaultWidth){
          this.defaultWidth = s.defaultWidth;
         }
        },
        adaptWidth: function(){
         // Only calculate this here - rather than every call to buildRowContent
         if(!("contentWidth" in this) && this.contentNode){
          this.contentWidth = this.contentNode.offsetWidth - this.padBorderWidth;
         }
    • summary
  • dojox.grid._Selector.doStyleRowNode

    • type
      Function
    • parameters:
      • inRowIndex: (typeof )
      • inRowNode: (typeof )
    • source: [view]
         var n = [ "dojoxGridRowbar dojoxGridNonNormalizedCell" ];
         if(this.grid.rows.isOver(inRowIndex)){
          n.push("dojoxGridRowbarOver");
         }
         if(this.grid.selection.isSelected(inRowIndex)){
          n.push("dojoxGridRowbarSelected");
         }
         inRowNode.className = n.join(" ");
    • summary
  • dojox.grid._Selector.onSelected

    • type
      Function
    • parameters:
      • inIndex: (typeof )
    • source: [view]
         this.grid.updateRow(inIndex);
    • summary
  • dojox.grid._Selector.onDeselected

    • type
      Function
    • parameters:
      • inIndex: (typeof )
    • source: [view]
         this.grid.updateRow(inIndex);
    • summary
  • dojox.grid._Selector.grid.selection.mode

    • summary
  • dojox.grid._Selector.scrollboxNode.style.overflow

    • summary
  • dojox.grid._Selector.contentWidth

    • summary
  • dojox.grid._RadioSelector

    • type
      Function
    • chains:
      • dojox.grid._Selector: (prototype)
      • dojox.grid._Selector: (call)
    • summary
  • dojox.grid._RadioSelector.inputType

    • summary
  • dojox.grid._RadioSelector.selectionMode

    • summary
  • dojox.grid._RadioSelector._contentBuilderClass

    • summary
  • dojox.grid._RadioSelector.buildRendering

    • type
      Function
    • source: [view]
         this.inherited(arguments);
         this.headerNode.style.visibility = "hidden";
    • summary
  • dojox.grid._RadioSelector.renderHeader

    • type
      Function
    • source: [view]
      }
    • summary
  • dojox.grid._RadioSelector.headerNode.style.visibility

    • summary
  • dojox.grid._CheckBoxSelector

    • type
      Function
    • chains:
      • dojox.grid._Selector: (prototype)
      • dojox.grid._Selector: (call)
    • summary
  • dojox.grid._CheckBoxSelector.inputType

    • summary
  • dojox.grid._CheckBoxSelector._headerBuilderClass

    • summary
  • dojox.grid._CheckBoxSelector._contentBuilderClass

    • summary
  • dojox.grid._CheckBoxSelector.postCreate

    • type
      Function
    • source: [view]
         this.inherited(arguments);
         this.connect(this.grid, 'onSelectionChanged', 'onSelectionChanged');
         this.connect(this.grid, 'updateRowCount', '_updateVisibility');
    • summary
  • dojox.grid._CheckBoxSelector.renderHeader

    • type
      Function
    • source: [view]
         this.inherited(arguments);
         this._updateVisibility(this.grid.rowCount);
    • summary
  • dojox.grid._CheckBoxSelector._updateVisibility

    • type
      Function
    • parameters:
      • rowCount: (typeof )
    • source: [view]
         this.headerNode.style.visibility = rowCount ? "" : "hidden";
    • summary
  • dojox.grid._CheckBoxSelector.onSelectionChanged

    • type
      Function
    • source: [view]
         if(this._selectionChanging){ return; }
         var inputDiv = dojo.query('.dojoxGridCheckSelector', this.headerNode)[0];
         var g = this.grid;
         var s = (g.rowCount && g.rowCount == g.selection.getSelectedCount());
         g.allItemsSelected = s||false;
         dojo.toggleClass(inputDiv, "dijitChecked", g.allItemsSelected);
         dojo.toggleClass(inputDiv, "dijitCheckBoxChecked", g.allItemsSelected);
    • summary
  • dojox.grid._CheckBoxSelector.headerNode.style.visibility

    • summary
  • dojox.grid._InputSelectorHeaderBuilder

    • type
      Function
    • parameters:
      • view: (typeof )
    • source: [view]
        dojox.grid._HeaderBuilder.call(this, view);
    • chains:
      • dojox.grid._HeaderBuilder: (call)
    • mixins:
      • dojox.grid._HeaderBuilder.prototype: (prototype)
    • summary
  • dojox.grid._SelectorContentBuilder

    • type
      Function
    • parameters:
      • view: (typeof )
    • source: [view]
        dojox.grid._ContentBuilder.call(this, view);
    • chains:
      • dojox.grid._ContentBuilder: (call)
    • mixins:
      • dojox.grid._ContentBuilder.prototype: (prototype)
    • summary
  • dojox.grid._InputSelectorContentBuilder

    • type
      Function
    • parameters:
      • view: (typeof )
    • source: [view]
        dojox.grid._SelectorContentBuilder.call(this, view);
    • chains:
      • dojox.grid._SelectorContentBuilder: (call)
    • mixins:
      • dojox.grid._SelectorContentBuilder.prototype: (prototype)
    • summary
  • dojox.grid._Selector.content

    • summary
  • dojox.grid._Selector.header

    • summary
  • dojox.grid._Selector.headerNodeContainer.style.width

    • summary
  • dojox.grid._InputSelectorHeaderBuilder.generateHtml

    • type
      Function
    • source: [view]
         var w = this.view.contentWidth || 0;
         var selectedCount = this.view.grid.selection.getSelectedCount();
         var checked = (selectedCount && selectedCount == this.view.grid.rowCount) ? ' dijitCheckBoxChecked dijitChecked' : '';
         return '    'border="0" cellspacing="0" cellpadding="0" ' +
          'role="presentation">
      ' +
          '
      ';
    • summary
  • dojox.grid._InputSelectorHeaderBuilder.doclick

    • type
      Function
    • parameters:
      • e: (typeof )
    • source: [view]
         var selectedCount = this.view.grid.selection.getSelectedCount();


         this.view._selectionChanging = true;
         if(selectedCount==this.view.grid.rowCount){
          this.view.grid.selection.deselectAll();
         }else{
          this.view.grid.selection.selectRange(0, this.view.grid.rowCount-1);
         }
         this.view._selectionChanging = false;
         this.view.onSelectionChanged();
         return true;
    • summary
  • dojox.grid._InputSelectorHeaderBuilder.view._selectionChanging

    • summary
  • dojox.grid._SelectorContentBuilder.generateHtml

    • type
      Function
    • parameters:
      • inDataIndex: (typeof )
      • inRowIndex: (typeof )
    • source: [view]
         var w = this.view.contentWidth || 0;
         return '    'cellspacing="0" cellpadding="0" role="presentation">' +
          '
      ' + this.getCellContent(inRowIndex) + '
      ';
    • summary
  • dojox.grid._SelectorContentBuilder.getCellContent

    • type
      Function
    • parameters:
      • inRowIndex: (typeof )
    • source: [view]
         return ' ';
    • summary
  • dojox.grid._SelectorContentBuilder.findTarget

    • type
      Function
    • source: [view]
         var t = dojox.grid._ContentBuilder.prototype.findTarget.apply(this, arguments);
         return t;
    • chains:
      • dojox.grid._ContentBuilder.prototype.findTarget: (call)
    • summary
  • dojox.grid._SelectorContentBuilder.domouseover

    • type
      Function
    • parameters:
      • e: (typeof )
    • source: [view]
         this.view.grid.onMouseOverRow(e);
    • summary
  • dojox.grid._SelectorContentBuilder.domouseout

    • type
      Function
    • parameters:
      • e: (typeof )
    • source: [view]
         if(!this.isIntraRowEvent(e)){
          this.view.grid.onMouseOutRow(e);
         }
    • summary
  • dojox.grid._SelectorContentBuilder.doclick

    • type
      Function
    • parameters:
      • e: (typeof )
    • source: [view]
         var idx = e.rowIndex;
         var selected = this.view.grid.selection.isSelected(idx);
         var mode = this.view.grid.selection.mode;


         if(!selected){
          if(mode == 'single'){
           this.view.grid.selection.select(idx);
          }else if(mode != 'none'){
           this.view.grid.selection.addToSelection(idx);
          }
         }else{
          this.view.grid.selection.deselect(idx);
         }


         return true;
    • summary
  • dojox.grid._InputSelectorContentBuilder.getCellContent

    • type
      Function
    • parameters:
      • rowIndex: (typeof )
    • source: [view]
         var v = this.view;
         var type = v.inputType == "checkbox" ? "CheckBox" : "Radio";
         var checked = !!v.grid.selection.isSelected(rowIndex) ? ' dijit' + type + 'Checked dijitChecked' : '';
         return '
      ';
    • summary
  • dojox.grid

    • type
      Object
    • summary
  • dojox

    • type
      Object
    • summary