在内联编辑JQGrid时是否可以显示微调器?

时间:2015-02-18 05:52:54

标签: jqgrid jqgrid-asp.net mvcjqgrid

我正在使用JQGrid。在内联编辑JQGrid并将数据保存到DB时,需要一些时间,在此期间我的页面变得无法响应。因此,在那个时间跨度内,我可以显示微调器向用户显示您编辑的数据是"正在更新..." 我正在使用以下代码 jqgrid init

 LoadProjectDetailsGrid = function () {
    var myGrid = $('#jqgProjectLists');
    myGrid.jqGrid("GridUnload");
    myGrid.jqGrid({
        url: '@Url.Action("GetProjectLists", "Config")',
        editurl: '@Url.Action("UpdateProjectListGrid", "Config")',
        datatype: 'json',
        mtype: 'POST',
        contentType: 'application/json; charset-utf-8',
        colNames: ['ID', 'PJT', 'Full Name', 'Model Type', 'Pjt Code', 'Model State', 'Project Type', 'Dev. Department',
                   'Client Model Name1', 'Client Model Name2', 'Client Model Name3', 'Model Status', 'Action'],
        colModel: [
                    { name: 'Model_ID', index: 'Model_ID', width: 100, sortable: true, align: 'left', editable: false, search: false, hidden: true },
                    { name: 'PJT_Nm', index: 'PJT_Nm', width: 150, sortable: true, align: 'left', editable: false, search: true, stype: 'text', searchoptions: { sopt: ['cn', 'eq', 'ne'] }, searchrules: { required: true } },
                    { name: 'Model_Nm', index: 'Model_Nm', width: 140, sortable: true, align: 'left', editable: false, search: true, stype: 'text', searchoptions: { sopt: ['cn', 'eq', 'ne'] }, searchrules: { required: true } },
                    { name: 'Model_Type', index: 'Model_Type', width: 80, sortable: true, align: 'center', editable: false, search: false },
                    { name: 'PJT_Code', index: 'PJT_Code', width: 100, sortable: true, align: 'left', editable: false, search: false, hidden: true },
                    { name: 'Model_State', index: 'Model_State', width: 110, sortable: true, align: 'center', editable: false, search: false },
                    { name: 'PJT_Type', index: 'PJT_Type', width: 100, sortable: true, align: 'center', editable: false, search: false },
                    { name: 'Dev_Dept_Nm_En', index: 'Dev_Dept_Nm_En', width: 200, sortable: true, align: 'left', editable: false, search: false },
                    { name: 'Client_Model_Nm1', index: 'Client_Model_Nm1', width: 120, sortable: true, align: 'left', editable: true, search: false, edittype: "text", editoptions: { size: "20", maxlength: "29" }},
                    { name: 'Client_Model_Nm2', index: 'Client_Model_Nm2', width: 120, sortable: true, align: 'left', editable: true, search: false, edittype: "text", editoptions: { size: "20", maxlength: "29" }},
                    { name: 'Client_Model_Nm3', index: 'Client_Model_Nm3', width: 120, sortable: true, align: 'left', editable: true, search: false, edittype: "text", editoptions: { size: "20", maxlength: "29" }},
                    { name: 'Model_Status', index: 'Model_Status', width: 100, sortable: true, align: 'center', editable: true, search: false, edittype: 'checkbox', editoptions: { value: "Y:N" }},
                    { name: 'Action', index: 'Action', width: 70, sortable: false, formatter: 'actions', viewable: false, search: false, formatoptions: { keys: true, editformbutton: false, editbutton: true, delbutton: false } }

        ],
        pager: '#jqgProjectListPager',
        rowNum: 10,
        rowList: [10, 20, 30, 100],
        sortname: 'PJT_Nm',
        sortorder: "desc",
        autowidth: true,
        shrinkToFit: true,
        viewrecords: true,
        gridview: true,
        loadonce: true,
        rownumbers: true,
        rownumWidth: 30,
        height: 'auto',
        width: 'auto',
        caption: "  " + "PROJECT LIST",
        loadtext: "Loading ...",
        emptyrecords: "No data to display!",
        multiselect: false,
        prmNames: { id: "Model_ID" },
        cellsubmit: "remote",

    });
    // Navi(View, Add,...)search: false,
    myGrid.jqGrid('navGrid', '#jqgProjectListPager', { add: false, edit: false, del: false, search: true, view: true, refresh: true },
            //edit options
            {
            },
            //add options
            {},
            //del options
            {
            },
                //search options
           {
               searchOnEnter: true,
               closeOnEscape: true,
               reloadAfterSearch: true
           },
             // veiw options
            {
                width: 500, height: 'auto',
                closeOnEscape: true,
                beforeShowForm: function (form) {
                },
                afterShowForm: function (form) {
                },
                showHideColumn: function (form) {
                }
            }
         );
    $("#jqgProjectLists").jqGrid('inlineNav', '#jqgProjectListPager',
               {
                   add: false,
                   edit: true,
                   editicon: "ui-icon-pencil",
                   save: true,
                   saveicon: "ui-icon-disk",
                   savetext : "Save",
                   cancel: true,
                   cancelicon: "ui-icon-cancel",
                   canceltext: "Cancel",
                }
      );
//handles the grid resize on window resize
    ResizeJQGrid(myGrid, $(window));
}

在ConfigController中

    [AcceptVerbs(HttpVerbs.Post)]
    public JsonResult UpdateProjectListGrid(ProjectListsDetails oProjectListRow)
    {
        _configMgr.UpdateProjectListGrid(oProjectListRow, CurrentCaUser);
        JqGridDataRequest jqgdRequest = new JqGridDataRequest();
        JqGridDataResponse response = _configMgr.GetProjectLists(jqgdRequest, oProjectListRow, CurrentCaUser);

        var jsonData = new
        {
            total = response.TotalPages,
            page = jqgdRequest.page,
            records = response.TotalRecords,
            rows = response.Rows
        };

        return Json(jsonData, JsonRequestBehavior.AllowGet);
    }

1 个答案:

答案 0 :(得分:1)

好吧,你可以在beforeSubmit事件上显示你的微调器,并在你的jqgrid diffinition的编辑选项部分的afterSubmit事件中隐藏你的微调器,但你可以使用来自documentation的一些不同的事件

//edit options
{
   beforeSubmit : function(postdata, formid) { 
      $("#your-spinner").show();
      return[true,'']; 
   },
   afterSubmit : function(response, postdata) 
   { 
      $("#your-spinner").hide();
      return [true,''] 
   }
},