【问题标题】:Event that is taking place after inline edit内联编辑后发生的事件
【发布时间】:2016-05-27 18:04:13
【问题描述】:

我有 jqgrid,它在选择行时将行的数据发送到另一个视图 (MVC4)。但是当我编辑行的信息(我正在使用内联编辑)时,这个视图没有改变。而且我找不到内联编辑后发生的事件。这是js,行编辑后我应该改变什么来改变我的视图

  $(function () {
$("#GridTable").jqGrid({
    url: "/Goods/GoodsList",
    editurl: "/Goods/Edit",
    datatype: 'json',
    mtype: 'Get',
    colNames: ['GoodId', 'Имя', 'Цена'],
    colModel: [
        { key: true, hidden: true, name: 'GoodId', index: 'GoodId', editable: true },
        {
            key: false, name: 'GoodName', index: 'GoodName', editable: true, sortable: true,
            editrules: {
                required: true, custom: true, custom_func: notATag
            }
        },
        {
            key: false, name: 'Price', index: 'Price', editable: true, sortable: true, formatter: numFormat,
            unformat: numUnformat,
            //sorttype: 'float',
            editrules: { required: true, custom: true, custom_func: figureValid}
        }, ],
    pager: jQuery('#pager'),
    rowNum: 10,
    rowList: [10, 25, 50, 100],
    height: '100%',
    viewrecords: true,
    caption: 'Список товаров',
    sortable: true,
    emptyrecords: 'No records to display',
    cellsubmit : 'remote',
    jsonReader: {
        root: "rows",
        page: "page",
        total: "total",
        records: "records",
        repeatitems: false,
        Id: "0"
    },
    //to get good's full view when row is selected
    onSelectRow:

        function () {
            var myGrid = $('#GridTable'),
            selRowId = myGrid.jqGrid('getGridParam', 'selrow'),
            celValue = myGrid.jqGrid('getCell', selRowId, 'GoodId');
            $.ajax({
                url: "/Goods/DetailInfo",
                type: "GET",
                data: { id: celValue }
            })
            .done(function (partialViewResult) {
                $("#goodDetInfo").html(partialViewResult);
            });
        },
    //to change good's full view after row deleting
    loadComplete: function(data){
        var myGrid = $('#GridTable'),
            selRowId = myGrid.jqGrid('getGridParam', 'selrow'),
            celValue = myGrid.jqGrid('getCell', selRowId, 'GoodId');
        $.ajax({
            url: "/Goods/DetailInfo",
            type: "GET",
            data: { id: celValue }
        })
        .done(function (partialViewResult) {
            $("#goodDetInfo").html(partialViewResult);
        });
    },
    autowidth: true,
    multiselect: false
}).navGrid('#pager', { edit: false, add: true, del: true, search: false, refresh: true },
    {
        // edit options
        zIndex: 100,
        url: '/Goods/Edit',
        closeOnEscape: true,
        closeAfterEdit: true,
        recreateForm: true,
        afterComplete: function (response) {
            if (response.responseText) {
                alert(response.responseText);
            }
            var myGrid = $('#GridTable'),
            selRowId = myGrid.jqGrid('getGridParam', 'selrow'),
            celValue = myGrid.jqGrid('getCell', selRowId, 'GoodId');
            $.ajax({
                url: "/Goods/DetailInfo",
                type: "GET",
                data: { id: celValue }
            })
            .done(function (partialViewResult) {
                $("#goodDetInfo").html(partialViewResult);
            });
        }
    },
    {
        // add options
        zIndex: 100,
        url: "/Goods/Create",
        closeOnEscape: true,
        closeAfterAdd: true,

        afterComplete: function (response) {
            if (response.responseText) {
                alert(response.responseText);
            }
        }
    },
    {
        // delete options
        zIndex: 100,
        url: "/Goods/Delete",
        closeOnEscape: true,
        closeAfterDelete: true,
        recreateForm: true,
        msg: "Are you sure you want to delete this task?",
        afterComplete: function (response) {
            if (response.responseText) {
                alert(response.responseText);
            }
        }
    });

$('#GridTable').inlineNav('#pager', {
    edit: true,
    add: false,
    del: false,
    cancel: true,
    editParams: {
        keys: true,
        afterSubmit: function (response) {
            if (response.responseText) {
                alert(response.responseText);
            }
            var myGrid = $('#GridTable'),
            selRowId = myGrid.jqGrid('getGridParam', 'selrow'),
            celValue = myGrid.jqGrid('getCell', selRowId, 'GoodId');
            $.ajax({
                url: "/Goods/DetailInfo",
                type: "GET",
                data: { id: celValue }
            })
            .done(function (partialViewResult) {
                $("#goodDetInfo").html(partialViewResult);
            });
        }
    },
});

});

【问题讨论】:

    标签: asp.net-mvc-4 jqgrid jqgrid-asp.net


    【解决方案1】:

    inlineNaveditParams参数的属性和回调函数可以在here找到。您需要的可能是aftersavefuncsuccessfunc 而不是afterSubmit,它们仅存在于表单编辑方法中(参见here)。 aftersavefuncsuccessfunc 回调的参数描述为 here(作为 saveRow 的参数),但参数取决于您使用的 jqGrid 版本和来自 jqGrid 的分支(free jqGrid,商业Guriddo jqGrid JS 或版本

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-18
      • 2011-06-19
      • 1970-01-01
      • 1970-01-01
      • 2011-09-16
      相关资源
      最近更新 更多