dojox/grid/_EditManager.js

  • Provides:

    • dojox.grid._EditManager
  • Requires:

    • dojox.grid.util in common
  • dojox.grid._EditManager

    • type
      Function
    • summary
      Controls grid cell editing process. Owned by grid and used internally for editing.
    • parameters:
      • inGrid: (typeof dojox.Grid)
        The dojox.Grid this editor should be attached to
    • source: [view]
        this.grid = inGrid;
        if(dojo.isIE){
         this.connections = [dojo.connect(document.body, "onfocus", dojo.hitch(this, "_boomerangFocus"))];
        }else{
         this.connections = [dojo.connect(this.grid, 'onBlur', this, 'apply')];
        }
  • dojox.grid._EditManager.info

    • type
      Object
    • summary
  • dojox.grid._EditManager.destroy

    • type
      Function
    • source: [view]
        dojo.forEach(this.connections,dojo.disconnect);
    • summary
  • dojox.grid._EditManager.cellFocus

    • type
      Function
    • parameters:
      • inCell: (typeof cell)
        object
        Grid cell object
      • inRowIndex: (typeof Integer)
        Grid row index
    • source: [view]
        if(this.grid.singleClickEdit || this.isEditRow(inRowIndex)){
         // if same row or quick editing, edit
         this.setEditCell(inCell, inRowIndex);
        }else{
         // otherwise, apply any pending row edits
         this.apply();
        }
        // if dynamic or static editing...
        if(this.isEditing() || (inCell && inCell.editable && inCell.alwaysEditing)){
         // let the editor focus itself as needed
         this._focusEditor(inCell, inRowIndex);
        }
    • summary
      Invoke editing when cell is focused
    • chains:
      • this: (call)
  • dojox.grid._EditManager.rowClick

    • type
      Function
    • parameters:
      • e: (typeof )
    • source: [view]
        if(this.isEditing() && !this.isEditRow(e.rowIndex)){
         this.apply();
        }
    • chains:
      • this: (call)
    • summary
  • dojox.grid._EditManager.styleRow

    • type
      Function
    • parameters:
      • inRow: (typeof )
    • source: [view]
        if(inRow.index == this.info.rowIndex){
         inRow.customClasses += ' dojoxGridRowEditing';
        }
    • summary
  • dojox.grid._EditManager.dispatchEvent

    • type
      Function
    • parameters:
      • e: (typeof )
    • source: [view]
        var c = e.cell, ed = (c && c["editable"]) ? c : 0;
        return ed && ed.dispatchEvent(e.dispatch, e);
    • summary
  • dojox.grid._EditManager.isEditing

    • type
      Function
    • source: [view]
        return this.info.rowIndex !== undefined;
    • summary
      Indicates editing state of the grid.
    • return_summary
      Boolean
      True if grid is actively editing
  • dojox.grid._EditManager.isEditCell

    • type
      Function
    • parameters:
      • inRowIndex: (typeof Integer)
        Grid row index
      • inCellIndex: (typeof Integer)
        Grid cell index
    • source: [view]
        return (this.info.rowIndex === inRowIndex) && (this.info.cell.index == inCellIndex);
    • summary
      Indicates if the given cell is being edited.
    • return_summary
      Boolean
      True if given cell is being edited
  • dojox.grid._EditManager.isEditRow

    • type
      Function
    • parameters:
      • inRowIndex: (typeof Integer)
        Grid row index
    • source: [view]
        return this.info.rowIndex === inRowIndex;
    • summary
      Indicates if the given row is being edited.
    • return_summary
      Boolean
      True if given row is being edited
  • dojox.grid._EditManager.setEditCell

    • type
      Function
    • parameters:
      • inCell: (typeof Object)
        Grid cell object
      • inRowIndex: (typeof Integer)
        Grid row index
    • source: [view]
        if(!this.isEditCell(inRowIndex, inCell.index) && this.grid.canEdit && this.grid.canEdit(inCell, inRowIndex)){
         this.start(inCell, inRowIndex, this.isEditRow(inRowIndex) || inCell.editable);
        }
    • summary
      Set the given cell to be edited
  • dojox.grid._EditManager._focusEditor

    • type
      Function
    • parameters:
      • inCell: (typeof )
      • inRowIndex: (typeof )
    • source: [view]
        dojox.grid.util.fire(inCell, "focus", [inRowIndex]);
    • summary
  • dojox.grid._EditManager.focusEditor

    • type
      Function
    • source: [view]
        if(this.isEditing()){
         this._focusEditor(this.info.cell, this.info.rowIndex);
        }
    • summary
  • dojox.grid._EditManager._boomerangWindow

    • summary
  • dojox.grid._EditManager._shouldCatchBoomerang

    • type
      Function
    • source: [view]
        return this._catchBoomerang > new Date().getTime();
    • summary
  • dojox.grid._EditManager._boomerangFocus

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


      dojo.require("dojox.grid.util");


      dojo.declare("dojox.grid._EditManager", null, {
       // summary:
       //  Controls grid cell editing process. Owned by grid and used internally for editing.
       constructor: function(inGrid){
        // inGrid: dojox.Grid
        //  The dojox.Grid this editor should be attached to
        this.grid = inGrid;
        if(dojo.isIE){
         this.connections = [dojo.connect(document.body, "onfocus", dojo.hitch(this, "_boomerangFocus"))];
        }else{
         this.connections = [dojo.connect(this.grid, 'onBlur', this, 'apply')];
        }
       },

       
       info: {},


       destroy: function(){
        dojo.forEach(this.connections,dojo.disconnect);
       },


       cellFocus: function(inCell, inRowIndex){
        // summary:
        //  Invoke editing when cell is focused
        // inCell: cell object
        //  Grid cell object
        // inRowIndex: Integer
        //  Grid row index
        if(this.grid.singleClickEdit || this.isEditRow(inRowIndex)){
         // if same row or quick editing, edit
         this.setEditCell(inCell, inRowIndex);
        }else{
         // otherwise, apply any pending row edits
         this.apply();
        }
        // if dynamic or static editing...
        if(this.isEditing() || (inCell && inCell.editable && inCell.alwaysEditing)){
         // let the editor focus itself as needed
         this._focusEditor(inCell, inRowIndex);
        }
       },


       rowClick: function(e){
        if(this.isEditing() && !this.isEditRow(e.rowIndex)){
         this.apply();
        }
       },


       styleRow: function(inRow){
        if(inRow.index == this.info.rowIndex){
         inRow.customClasses += ' dojoxGridRowEditing';
        }
       },


       dispatchEvent: function(e){
        var c = e.cell, ed = (c && c["editable"]) ? c : 0;
        return ed && ed.dispatchEvent(e.dispatch, e);
       },


       // Editing
       isEditing: function(){
        // summary:
        //  Indicates editing state of the grid.
        // returns: Boolean
        //   True if grid is actively editing
        return this.info.rowIndex !== undefined;
       },


       isEditCell: function(inRowIndex, inCellIndex){
        // summary:
        //  Indicates if the given cell is being edited.
        // inRowIndex: Integer
        //  Grid row index
        // inCellIndex: Integer
        //  Grid cell index
        // returns: Boolean
        //   True if given cell is being edited
        return (this.info.rowIndex === inRowIndex) && (this.info.cell.index == inCellIndex);
       },


       isEditRow: function(inRowIndex){
        // summary:
        //  Indicates if the given row is being edited.
        // inRowIndex: Integer
        //  Grid row index
        // returns: Boolean
        //   True if given row is being edited
        return this.info.rowIndex === inRowIndex;
       },


       setEditCell: function(inCell, inRowIndex){
        // summary:
        //  Set the given cell to be edited
        // inRowIndex: Integer
        //  Grid row index
        // inCell: Object
        //  Grid cell object
        if(!this.isEditCell(inRowIndex, inCell.index) && this.grid.canEdit && this.grid.canEdit(inCell, inRowIndex)){
         this.start(inCell, inRowIndex, this.isEditRow(inRowIndex) || inCell.editable);
        }
       },


       _focusEditor: function(inCell, inRowIndex){
        dojox.grid.util.fire(inCell, "focus", [inRowIndex]);
       },


       focusEditor: function(){
        if(this.isEditing()){
         this._focusEditor(this.info.cell, this.info.rowIndex);
        }
       },


       // implement fix for focus boomerang effect on IE
       _boomerangWindow: 500,
       _shouldCatchBoomerang: function(){
        return this._catchBoomerang > new Date().getTime();
       },
       _boomerangFocus: function(){
        //console.log("_boomerangFocus");
        if(this._shouldCatchBoomerang()){
         // make sure we don't utterly lose focus
         this.grid.focus.focusGrid();
         // let the editor focus itself as needed
         this.focusEditor();
         // only catch once
         this._catchBoomerang = 0;
        }
    • summary
  • dojox.grid._EditManager._doCatchBoomerang

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


      dojo.require("dojox.grid.util");


      dojo.declare("dojox.grid._EditManager", null, {
       // summary:
       //  Controls grid cell editing process. Owned by grid and used internally for editing.
       constructor: function(inGrid){
        // inGrid: dojox.Grid
        //  The dojox.Grid this editor should be attached to
        this.grid = inGrid;
        if(dojo.isIE){
         this.connections = [dojo.connect(document.body, "onfocus", dojo.hitch(this, "_boomerangFocus"))];
        }else{
         this.connections = [dojo.connect(this.grid, 'onBlur', this, 'apply')];
        }
       },

       
       info: {},


       destroy: function(){
        dojo.forEach(this.connections,dojo.disconnect);
       },


       cellFocus: function(inCell, inRowIndex){
        // summary:
        //  Invoke editing when cell is focused
        // inCell: cell object
        //  Grid cell object
        // inRowIndex: Integer
        //  Grid row index
        if(this.grid.singleClickEdit || this.isEditRow(inRowIndex)){
         // if same row or quick editing, edit
         this.setEditCell(inCell, inRowIndex);
        }else{
         // otherwise, apply any pending row edits
         this.apply();
        }
        // if dynamic or static editing...
        if(this.isEditing() || (inCell && inCell.editable && inCell.alwaysEditing)){
         // let the editor focus itself as needed
         this._focusEditor(inCell, inRowIndex);
        }
       },


       rowClick: function(e){
        if(this.isEditing() && !this.isEditRow(e.rowIndex)){
         this.apply();
        }
       },


       styleRow: function(inRow){
        if(inRow.index == this.info.rowIndex){
         inRow.customClasses += ' dojoxGridRowEditing';
        }
       },


       dispatchEvent: function(e){
        var c = e.cell, ed = (c && c["editable"]) ? c : 0;
        return ed && ed.dispatchEvent(e.dispatch, e);
       },


       // Editing
       isEditing: function(){
        // summary:
        //  Indicates editing state of the grid.
        // returns: Boolean
        //   True if grid is actively editing
        return this.info.rowIndex !== undefined;
       },


       isEditCell: function(inRowIndex, inCellIndex){
        // summary:
        //  Indicates if the given cell is being edited.
        // inRowIndex: Integer
        //  Grid row index
        // inCellIndex: Integer
        //  Grid cell index
        // returns: Boolean
        //   True if given cell is being edited
        return (this.info.rowIndex === inRowIndex) && (this.info.cell.index == inCellIndex);
       },


       isEditRow: function(inRowIndex){
        // summary:
        //  Indicates if the given row is being edited.
        // inRowIndex: Integer
        //  Grid row index
        // returns: Boolean
        //   True if given row is being edited
        return this.info.rowIndex === inRowIndex;
       },


       setEditCell: function(inCell, inRowIndex){
        // summary:
        //  Set the given cell to be edited
        // inRowIndex: Integer
        //  Grid row index
        // inCell: Object
        //  Grid cell object
        if(!this.isEditCell(inRowIndex, inCell.index) && this.grid.canEdit && this.grid.canEdit(inCell, inRowIndex)){
         this.start(inCell, inRowIndex, this.isEditRow(inRowIndex) || inCell.editable);
        }
       },


       _focusEditor: function(inCell, inRowIndex){
        dojox.grid.util.fire(inCell, "focus", [inRowIndex]);
       },


       focusEditor: function(){
        if(this.isEditing()){
         this._focusEditor(this.info.cell, this.info.rowIndex);
        }
       },


       // implement fix for focus boomerang effect on IE
       _boomerangWindow: 500,
       _shouldCatchBoomerang: function(){
        return this._catchBoomerang > new Date().getTime();
       },
       _boomerangFocus: function(){
        //console.log("_boomerangFocus");
        if(this._shouldCatchBoomerang()){
         // make sure we don't utterly lose focus
         this.grid.focus.focusGrid();
         // let the editor focus itself as needed
         this.focusEditor();
         // only catch once
         this._catchBoomerang = 0;
        }
       },
       _doCatchBoomerang: function(){
        // give ourselves a few ms to boomerang IE focus effects
        if(dojo.isIE){this._catchBoomerang = new Date().getTime() + this._boomerangWindow;}
    • summary
  • dojox.grid._EditManager.start

    • type
      Function
    • parameters:
      • inCell: (typeof )
      • inRowIndex: (typeof )
      • inEditing: (typeof )
    • source: [view]
        this.grid.beginUpdate();
        this.editorApply();
        if(this.isEditing() && !this.isEditRow(inRowIndex)){
         this.applyRowEdit();
         this.grid.updateRow(inRowIndex);
        }
        if(inEditing){
         this.info = { cell: inCell, rowIndex: inRowIndex };
         this.grid.doStartEdit(inCell, inRowIndex);
         this.grid.updateRow(inRowIndex);
        }else{
         this.info = {};
        }
        this.grid.endUpdate();
        // make sure we don't utterly lose focus
        this.grid.focus.focusGrid();
        // let the editor focus itself as needed
        this._focusEditor(inCell, inRowIndex);
        // give ourselves a few ms to boomerang IE focus effects
        this._doCatchBoomerang();
    • summary
  • dojox.grid._EditManager._editorDo

    • type
      Function
    • parameters:
      • inMethod: (typeof )
    • source: [view]
        var c = this.info.cell;
        //c && c.editor && c.editor[inMethod](c, this.info.rowIndex);
        if(c && c.editable){
         c[inMethod](this.info.rowIndex);
        }
    • summary
  • dojox.grid._EditManager.editorApply

    • type
      Function
    • source: [view]
        this._editorDo("apply");
    • summary
  • dojox.grid._EditManager.editorCancel

    • type
      Function
    • source: [view]
        this._editorDo("cancel");
    • summary
  • dojox.grid._EditManager.applyCellEdit

    • type
      Function
    • parameters:
      • inValue: (typeof )
      • inCell: (typeof )
      • inRowIndex: (typeof )
    • source: [view]
        if(this.grid.canEdit(inCell, inRowIndex)){
         this.grid.doApplyCellEdit(inValue, inRowIndex, inCell.field);
        }
    • summary
  • dojox.grid._EditManager.applyRowEdit

    • type
      Function
    • source: [view]
        this.grid.doApplyEdit(this.info.rowIndex, this.info.cell.field);
    • summary
  • dojox.grid._EditManager.apply

    • type
      Function
    • source: [view]
        if(this.isEditing()){
         this.grid.beginUpdate();
         this.editorApply();
         this.applyRowEdit();
         this.info = {};
         this.grid.endUpdate();
         this.grid.focus.focusGrid();
         this._doCatchBoomerang();
        }
    • summary
      Apply a grid edit
  • dojox.grid._EditManager.cancel

    • type
      Function
    • source: [view]
        if(this.isEditing()){
         this.grid.beginUpdate();
         this.editorCancel();
         this.info = {};
         this.grid.endUpdate();
         this.grid.focus.focusGrid();
         this._doCatchBoomerang();
        }
    • summary
      Cancel a grid edit
  • dojox.grid._EditManager.save

    • type
      Function
    • parameters:
      • inRowIndex: (typeof Integer)
        Grid row index
      • inView: (typeof Object)
        Grid view
    • source: [view]
        var c = this.info.cell;
        if(this.isEditRow(inRowIndex) && (!inView || c.view==inView) && c.editable){
         c.save(c, this.info.rowIndex);
        }
    • summary
      Save the grid editing state
  • dojox.grid._EditManager.restore

    • type
      Function
    • parameters:
      • inView: (typeof Object)
        Grid view
      • inRowIndex: (typeof Integer)
        Grid row index
    • source: [view]
        var c = this.info.cell;
        if(this.isEditRow(inRowIndex) && c.view == inView && c.editable){
         c.restore(c, this.info.rowIndex);
        }
    • summary
      Restores the grid editing state
  • dojox.grid._EditManager.info.rowIndex

    • summary
  • dojox.grid._EditManager._catchBoomerang

    • summary
  • dojox.grid._EditManager.grid

    • summary
  • dojox.grid._EditManager.connections

    • summary
  • dojox.grid

    • type
      Object
    • summary
  • dojox

    • type
      Object
    • summary