模式关闭后,PostCloseEvent不触发

时间:2019-09-18 18:43:51

标签: jquery datatable simplemodal

我有一个模态窗口,已打开,输入数据,保存在后端,然后关闭。我有一个PostCloseEvent,应该在模式关闭后调用。我在函数中有一个调试器,实际上在加载模式之前会调用它。

第一个模式是否以某种方式抛弃了我打算为d.loadLookupContent('UserDefinedFormLookup');进行的后关闭?

        $("#btn_mnc_form_add").off('click').on('click', function (e) {
            //e.preventDefault();
            $.jStorage.set('AuthPlanHeader_I_ToSaveWithUDF', g.AuthHeaderId);

            customObjects.addUDFLookupObj({ formType: 'MNC', entityId: 1, host: 'MNC', mode: 'addForm', parent: 'reviewauthorizationrequest' });  //creates and displays a modal
            $(document).on('PostCloseEvent', reviewauthorizationrequest.reloadMNCGrid);
            d.loadLookupContent('UserDefinedFormLookup');  //loads the data of another modal form
        });

    function refreshMNCGrid() {
        //$(MNCFormGrid).trigger("reloadGrid", [{ page: 1 }]);
        $(MNCFormGrid).DataTable().ajax.reload();
    }

    function _reloadMNCGrid() {
        debugger;

        refreshMNCGrid();
        bindMNCGrid();
    }

function bindMNCGrid() {
        $('.MNCSection').show();

        if ($.fn.DataTable.isDataTable(MNCFormGrid)) {
            let _table = $(MNCFormGrid).DataTable();
            _table.ajax.reload(null, true);
            return;
        }

        $(MNCFormGrid).DataTable({
            serverSide: true,
            responsive: true,
            searching: false,
            //paging: true,
            order: [[1, "desc"]],
            pageLength: 10,
            lengthMenu: [[10, 15, 20, 25], [10, 15, 20, 25]],
            columns: [
                { title: '', name: 'UserDefinedFormData_ID', visible: false },
                { title: '', name: 'FormId', visible: false },
                { title: 'Review Name', name: 'ReviewName' },
                { title: 'Disposition', name: 'Disposition' },
                { title: 'Reviewed By', name: 'Reviewed_By' },
                { title: 'Review Date', name: 'ReviewDate' }
            ],
            ajax: function (data, callback, settings) {
                _filterdata = {};

                _filterdata.DiInsur = !(g.diInsur) ? null : g.diInsur;
                _filterdata.PageSize = data.length;
                _filterdata.PageIndex = data.start;
                _filterdata.PatientId = g.patientId;

                let _column = data.columns[data.order[0].column].data;
                let _orderBy = "";
                let _dir = data.order[0].dir;
                switch (_column) {
                    case 0:
                        _orderBy = 'UserDefinedFormData_ID' + ' ' + _dir;
                        break;
                    case 1:
                        _orderBy = 'FormId' + ' ' + _dir;
                        break;
                    case 2:
                        _orderBy = 'ReviewName' + ' ' + _dir;
                        break;
                    case 3:
                        _orderBy = 'Disposition' + ' ' + _dir;
                        break;
                    case 4:
                        _orderBy = 'Reviewed_By' + ' ' + _dir;
                        break;
                    case 5:
                        _orderBy = 'ReviewDate' + ' ' + _dir;
                        break;
                    default:
                        _orderBy = 'FormId' + ' ' + _dir;
                        break;
                }

                _filterdata.OrderBy = _orderBy;

                var search = {
                    authplanHeaderId: g.AuthHeaderId,
                    patientId: g.patientId,
                    udfId: null,
                    Guid: g.diInsur,
                    userId: g.userId,
                    provId: null,
                    product: g.userType == c.INCEDOUSER ? "Incedo" : "IPC",
                    limitAccessProvider: g.Limit_access_to_forms_entered_by_the_provider,
                    limitAccesstoUser: g.Limit_access_to_forms_entered_by_the_loggedin_user,
                    orderBy: _orderBy,
                    pageSize: data.length,
                    pageIndex: data.start
                };

                app.ajax({ values: search, url: 'Services/Workflow.svc/GetMNCFormslist' })
                    .done(function (jdata, status, jQhr) {
                        let _count = jdata.d.Count;

                        if (__reselect && __editedId)
                            detailId = __editedId;

                        let _rows = [];
                        $(jdata.d.list).each(function (index, obj) {
                            let _data = [];
                            _data.push(obj.UserDefinedFormData_ID);
                            _data.push(obj.FormId);
                            _data.push(obj.ReviewName);
                            _data.push(obj.Disposition);
                            _data.push(obj.Reviewed_By);
                            _data.push(obj.ReviewDate);
                            _rows.push(_data);
                        });

                        setTimeout(function () {
                            callback({
                                draw: data.draw,
                                iTotalRecords: _count,
                                iTotalDisplayRecords: _count,
                                data: _rows
                            });
                        }, 50);

                        setTimeout(function () {
                            let _table = $(MNCFormGrid).DataTable();
                            _table.$('tr:first').click();
                            _table.$('tr.selected').removeClass('selected');
                            $(this).addClass('selected');
                        }, 100);

                        selectFlag = true;

                        d.lockScreen = false;
                        d.progressIndicator(false);

                        return false;
                    });
            }

        });

        $('#MNCFormGrid tbody').on('click', 'tr', function () {
            let _table = $('#MNCFormGrid').DataTable();
            let data = _table.rows(this).data();
            if (g.Mode == 'add' || g.Mode == 'edit') return false;

            _table.$('tr.selected').removeClass('selected');
            $(this).addClass('selected');
        });
    }

0 个答案:

没有答案