$('#grid')。触发器('reloadGrid')没有关闭模态对话框

时间:2013-06-11 07:16:14

标签: jquery jqgrid

$(document).ready(function () {
    PopulateCombo();
    DateSetup();
    $("#grid").jqGrid({
        colNames: ['', 'Name', 'Company', 'Location', 'County', 'State', 'Effective Date',
            'Term Date', 'Created Date'],
        colModel: [
            {
                name: 'lease_id',
                index: 'lease_id',
                sortable: false,
                align: 'left',
                width: '80',
                editable: false,
                edittype: 'text',
                key: true,
                formatter: 'actions',
                formatoptions: {
                    keys: true,
                    editbutton: true,
                    delbutton: true,
                    delOptions: { reloadAfterSubmit: false },
                    editOptions: { reloadAfterSubmit: false },
                    onSuccess: function(data) {
                        ar res = $.parseJSON(data.responseText);
                        // return the inserted lease
                        lastse = res.Message;
                        // set selection on the returned lease
                        jQuery('#grid').jqGrid('setSelection', lastse);
                        // Populate the lease view tab at the botton with the lease
                        if (lastse == 'undefined') {
                            $.ajax({
                                type: 'GET',
                                url: '@Url.Action("LeaseView/")' + lastse,
                                dataType: "html",
                                success: function (result) {
                                    var domElement = $(result);
                                    // Out put the lease page html and set focus
                                    $("#partView").html(domElement);
                                    $('#tab1link').show();
                                    $('#tab1link').focus();
                                    $('#tab1link').click();
                                },
                                error: function (result) {
                                    alert(result.responseText);
                                }
                            });
                        }
                        return true;
                    }
                }
            },
            {
                name: 'lease_name',
                index: 'lease_name',
                sortable: false,
                align: 'left',
                width: '200',
                editable: true,
                edittype: 'text',
                editrules: {
                    custom: true,
                    custom_func: validate
                }
            },
            {
                name: 'company_id',
                index: 'company_id',
                sortable: false,
                align: 'left',
                width: '250',
                editable: true,
            }
        ],
        pager: jQuery('#pager'),
        sortname: 'lease_name',
        rowNum: 10,
        rowList: [10, 20, 25],
        sortorder: "",
        viewrecords: true,
        scrollOffset: 0,
        rownumbers: false,
        //caption: 'Leases',
        imgpath: '/Content/jqGridCss/smoothness/images',
        height: '100%',
        width: 1600,
        shrinkToFit: false,
        autoWidth: false,
        url: GetUrl(),
        editurl: "PerformLeaseCrudAction",
        datatype: 'json',
        mtype: 'GET',
        onSelectRow: function(lease_id) {
            // save the sate of the row on select
            if (lease_id && lease_id !== lastse) {
                jQuery('#grid').jqGrid('restoreRow', lastse);
                lastse = lease_id;
            }
            if (lease_id != 0) {
                // populate the lease tab
                $.ajax(
                    {
                        type: 'GET',
                        url: '@Url.Action("/LeaseView/")' + lease_id,
                        dataType: "html",
                        success: function(result) {
                            var domElement = $(result);
                            $("#partView").html(domElement);
                            $('#tab1link').show();
                            $('#tab1link').focus();
                            $('#tab1link').click();
                        },
                        error: function(result) {
                           // alert(result.responseText);
                        }
                    });
            }
        },
        // make the grid row editable
        ondblClickRow: function(lease_id) {
            if (lease_id && lease_id !== lastse) {
                jQuery('#grid').jqGrid('restoreRow', lastse);
                jQuery('#grid').jqGrid('editRow', lease_id, true);
                lastse = lease_id;
            }
        },
        gridComplete: function() {
            var grid = jQuery("#grid"),
            ids = grid.jqGrid("getDataIDs");
            if (ids && ids.length > 0)
                grid.jqGrid("setSelection", ids[0]);
            $('#tab1link').show();
            $('#tab1link').focus();
            $('#tab1link').click();
        }
    });

    // set grid navigation
    jQuery("#grid").jqGrid('navGrid', '#pager',
        { edit: false, add: false, del: false, search: false, refresh: false, viewrecords: false },
        { closeOnEscape: true, reloadAfterSubmit: false, closeAfterEdit: true, left: 400, top: 300 },
        { closeOnEscape: true, reloadAfterSubmit: false, closeAfterAdd: true, left: 450, top: 300, width: 520 },
        { closeOnEscape: true, reloadAfterSubmit: false, left: 450, top: 300 }
    );
});

我有一个jqGrid和行选择我刷新div partView有一个局部视图这个局部页面有标签。在其中一个标签上有一个编辑按钮,它在div“partView”中加载另一个局部视图“partialpage2”。单击其中一个按钮可打开模式弹出窗口。除模态局部视图之外的所有部分都使用Microsoft ajax obtrusive进行更新。当模式对话框关闭时,我无法重新加载jqGrid,并且所有datepicker事件都丢失了

<div id="partView">
          @{Html.RenderPartial("partialpage1", new x());}
</div>
<div id="modpage">
        <div id="LocationEditModal"></div>
      </div>
function OpenLocationEditModal(leaseId) {
    try {
        var latlongString;
        $Dialog_div = $("# modpage ").dialog({
            modal: true,
            width: '50%',
            height: $(window).height() * .9,
            title: 'Location Details',
            resizable: false,
            load: function () {
            },
            close: function () {
                $.bEditWindowOpen = false;
                $('#grid').trigger('reloadGrid');     // Not working
       });

0 个答案:

没有答案