0

我使用编辑表单对话框编辑网格。提交按钮后,我需要重新加载网格。我已经设置了 reloadAfterSubmit:true。这在我在网格上设置 mtype="POST" 时有效。提交编辑表单后,网格会立即重新加载。但我无法让寻呼机工作。

当我删除 mtype="POST" 时,寻呼机将工作,但编辑表单不会刷新网格。请给我一些意见。

$("#list").jqGrid({
                url: "../Hdlr.ashx?GetData",
                mtype: "POST",
               colNames: ['Id', 'Short Description', 'Long Description','', ''],
                colModel: [
                    { name: 'Id', index: 'Id', width: 50, align: 'left', editable: false },
                    { name: 'ShortDescription', index: 'ShortDescription', width: 200, align: 'left', sortable: true, editable: true, edittype: 'text', editrules: { required: true } },
                    { name: 'LongDescription', index: 'LongDescription', width: 200, align: 'left', sortable: true, editable: true, edittype: 'text', editrules: { required: true } },
                    { name: 'edit', width: 30, sortable: false, formatter: 'actions', formatoptions: { keys: true, editformbutton: true, delbutton: false, editbutton: false } },
                    { name: 'delete', width: 30, sortable: false, formatter: 'actions', formatoptions: { keys: true, editformbutton: false, delbutton: true, editbutton: false } }],
                postData: {
                    Category: function () { return $("#Category").val(); }
                },
                jsonReader: {
                    cell: "",
                    id: "0"
                },
                pager: '#pager',
                rowNum: 10,
                rowList: [10, 20, 50],
                rownumbers: true,
                sortname: 'Id',
                sortorder: "asc",
                viewrecords: true,
                caption: 'MY GridInformation'
            }).jqGrid("navGrid", "#pager", { edit: false, add: false, del: false, search: false });
        }

寻呼机不适用于 jqGrid 的这种简单声明。请帮忙

 $(function () {
            $("#list").jqGrid({
                url: "../Hdlr.ashx?method=GetData",
             mtype: 'POST',
                colNames: ['Id', 'Category', 'ShortDescription', 'LongDescription'],
                colModel: [
                    { name: 'Id', index: 'Id', width: 50, align: 'left', editable: false },
                    { name: 'Category', index: 'Category', width: 100, align: 'left', sortable: true },
                    { name: 'ShortDescription', index: 'ShortDescription', width: 200, align: 'left', sortable: true },
                    { name: 'LongDescription', index: 'LongDescription', width: 200, align: 'left', sortable: true }],
            jsonReader: {
                    cell: "",
                    id: "0"
                },
                pager: '#pager',
                rowNum: 10,
                rowList: [10, 20, 50],
                rownumbers: true,
              viewrecords: true,
                caption: 'Caption'
            }).jqGrid("navGrid", "#pager", { edit: false, add: false, del: false, search: false });
        });












    $.extend($.jgrid.edit, {
            editData: { Category: function () { return $("#Category").val(); } },
            url: '../Hdlr.ashx?SaveData',
            closeOnEscape: true,
            reloadAfterSubmit: true,
            closeAfterEdit: true,
            viewPagerButtons: false,
            });




I have removed edit and add options. The pager on grid is not working
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" runat="server">
     <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/redmond/jquery-ui.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" href="../Content/ui.jqgrid.css" type="text/css" />
    <script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.7.2.min.js"></script>
    <script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.20/jquery-ui.min.js"></script>
    <script type="text/javascript" src="../Scripts/grid.locale-en.js"></script>
    <script type="text/javascript" src="../Scripts/jquery.jqGrid.min.js"></script>

    <script type="text/javascript">
        $.jgrid.no_legacy_api = true;
        $.jgrid.useJSON = true;
    </script>
  <script type="text/javascript" src="../Scripts/Common.js"></script>

    <script type="text/javascript">
        $(function () {
            "use strict";

            $("#list").jqGrid({
                url: "../Hdlr.ashx?method=GetData",
                mtype: 'POST',
                colNames: ['Id'],
                colModel: [{ name: 'id', index: 'id', width: 500}],
                jsonReader: {cell: "0"},
                pager: '#pager',
                rowNum: 10,
                rowList: [10, 20, 50],
                caption: 'Grid Information'
            }).jqGrid("navGrid", "#pager", { edit: false, add: false, del: false, search: false });
        });
        </script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
      <table id="list">
                </table>
                <div id="pager"></div>
</asp:Content>

    enter code here
4

1 回答 1

0

例如,您可以构建自己的编辑函数,而不是扩展 jqGrid 设置,以便在连续按下按钮时调用。

function EditCollectionItem (rowid, grid){

    $(grid).jqGrid('editGridRow', rowid,
    {
        viewPagerButtons: false,
        editData: { ValueName: value },
        afterShowForm: function (formid) {
            //dostuff here if you wish, ex make a field have focus
        }, //afterShowForm
        afterComplete: function (response) {
          //deal with how the edit went
        } //afterComplete
    }); //$this.jqGrid('editGridRow

}//function EditCollectionItem (rowid, grid){

您可以在此处设置所有其他编辑选项,与您在原始代码中扩展它们的位置相同。

于 2013-04-08T14:08:30.523 回答