editor crash in .on('xhr.dt.dte' + this.s.unique, function (e, settings, json)

editor crash in .on('xhr.dt.dte' + this.s.unique, function (e, settings, json)

LapointeLapointe Posts: 430Questions: 81Answers: 4

Datatables.editor.js 2.0.10 run OK... testing if json

           .on('xhr.dt.dte' + this.s.unique, function (e, settings, json) {
           ** if (json && _this.s.table && settings.nTable === $(table$1)[0]) **{
                // Automatically update fields which have a field name defined in
                // the returned json - saves an `initComplete` for the user
                _this._optionsUpdate(json);
            }
        });

Datatables.editor.js V 2.1.0 NOK... If json is null, system crash (row 6693)

            .on('xhr.dt.dte' + this.s.unique, function (e, settings, json) {
            var table = _this.s.table;
            if (table) {
                var dtApi = new DataTable.Api(table);
                if (settings.nTable === dtApi.table().node()) {
                    // Automatically update fields which have a field name defined in
                    // the returned json - saves an `initComplete` for the user
                    _this._optionsUpdate(json);
                }
            }
        });

Replies

  • allanallan Posts: 63,482Questions: 1Answers: 10,467 Site admin

    Can you show me how you have configured your Editor instance, and any events you have attached to it please? Or even better, can you give me a link to the page so I can take a look please?

    Thanks,
    Allan

  • LapointeLapointe Posts: 430Questions: 81Answers: 4

    hi Allan
    As I said release 2.1.0 crash with a problem when option list is null so no json is returned (null)
    It was when browsing a table and editing rows. Some of them were ok and other not.
    I'm just afraid for deploying
    I'll give you a pwd in private mode to test.

  • LapointeLapointe Posts: 430Questions: 81Answers: 4

    Hi all
    I do test in r2.2.2. The problem does not exist anymore

  • allanallan Posts: 63,482Questions: 1Answers: 10,467 Site admin

    when option list is null so no json is returned (null)

    To confirm. The whole JSON on data load is null, the options object, or the specific field's options array/object?

    Allan

  • LapointeLapointe Posts: 430Questions: 81Answers: 4

    Yes Allan... JSON === NULL
    in V2.0.x, JSON value was tested, in 2.1.0 not...

  • allanallan Posts: 63,482Questions: 1Answers: 10,467 Site admin

    In our Ajax complete handler (for Editor, not DataTables) there is a test for the return being null (note as a string, not a "true" null).

    That was actually in 2.1.0 though.

    Allan

  • LapointeLapointe Posts: 430Questions: 81Answers: 4

    hi allan
    dataTables.editor.js, 2.1.0
    line 6693

                .on('xhr.dt.dte' + this.s.unique, function (e, settings, json) {
                var table = _this.s.table;
                if (table) {
                    var dtApi = new DataTable.Api(table);
                    if (settings.nTable === dtApi.table().node()) {
                        // Automatically update fields which have a field name defined in
                        // the returned json - saves an `initComplete` for the user
                        _this._optionsUpdate(json);
                    }
                }
            });
    

    line 4218

    function _optionsUpdate(json) {
        var that = this;
        if (json.options) {
            $.each(this.s.fields, function (name, field) {
                if (json.options[name] !== undefined) {
                    var fieldInst = that.field(name);
                    if (fieldInst && fieldInst.update) {
                        fieldInst.update(json.options[name]);
                    }
                }
            });
        }
    }
    

    So function is called with no test for json is null, and when calling json.options, error occurs if json is null

    Please let me know where I missunderstood

    Thank for all

    Bob
    Bob

  • allanallan Posts: 63,482Questions: 1Answers: 10,467 Site admin

    I'm with you now. Thanks for the clarification. The fix for that was in Editor 2.1.1:

    Fix: Guard against json being null in options update

    Allan

Sign In or Register to comment.