Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
135
Modal dialog not closing properly if initialized in different container then the grid itself with "Cannot read property 'focus' of undefined"
posted

An exception is being thrown while selecting different rows : 

The code from 16-1.lob : 

_selectionToggle: function (element, dontToggle) {
var sel = this.grid.element.data("igGridSelection");
if (!sel) {
return;
}
sel._suspend = !sel._suspend;
if (element || dontToggle) {
this._actElement = element;
} else {
this._actElement.focus();
}
},

The bug, IMHO, is that the state of the grid while entering the method is not good enough to process. Here are the states of the different variables : 

this._actElement === undefined
-> true
dontToggle
-> undefined
element
-> null

The error message and stack trace are : 

Uncaught TypeError: Cannot read property 'focus' of undefined(…)

(anonymous function) @ VM1908:1

InjectedScript._evaluateOn @ (program):145

InjectedScript._evaluateAndWrap @ (program):137

InjectedScript.evaluateOnCallFrame @ (program):151

$.widget._selectionToggle @ infragistics.lob-16.1.js:69400

(anonymous function) @ jquery-ui-1.10.3.js:401

$.widget._endEdit @ infragistics.lob-16.1.js:68700

(anonymous function) @ jquery-ui-1.10.3.js:401

$.widget._mouseDown @ infragistics.lob-16.1.js:67923

(anonymous function) @ jquery-ui-1.10.3.js:401

proxy @ jquery-1.9.1.js:818jQuery.event.dispatch @ jquery-1.9.1.js:3074

elemData.handle @ jquery-1.9.1.js:2750


this._actElement

Parents
  • 135
    Verified Answer
    posted

    The previous version has a bug. This is my latest patch which uses internally the girds own public API which does the job. Here is the modification to the _mouseDown method : 

    _mouseDown: function (evt) {

    ...

    if (this.isEditing()) {
    // can be uncommented for blocking done/cancel buttons
    //if (this.options.editMode === "cell" || !this.options.showDoneCancelButtons) {
    // close editing if the end-user clicked somewhere else
    // this will re-enable selection and allow for subsequent start edit which is
    // at this point blocked indefinately because of the inability to select anything
    if (!target.hasClass(this.css.editingCell) &&
    (this.options.editMode === "cell" || this._getRowId(target.closest("tr")) !== this._editingForRowId)) {

    // Here is the little modification which checks if we are in dialog mode.

    if (this.options.editMode === "dialog") {
    this.endEdit(false, true);
    }
    else {
    this._endEdit(evt, true, false);
    }
    }
    //}
    }

    ...

    },

Reply Children
No Data