从 JqGrid 中检索编辑的数据并在 Web 中使用它 Api

Retrieve the edited data from JqGrid and use it in Web Api

假设我有 form. 我想编辑一行并提交。 我的 PUT 代码为:

$("#jqgrid").jqGrid('navGrid', pagerSelector,
                {
                    //navbar options
                    edit: true,
                    editicon: 'ace-icon fa fa-pencil blue',
                    add: true,
                    addicon: 'ace-icon fa fa-plus-circle purple',
                    del: true,
                    delicon: 'ace-icon fa fa-trash-o red',
                    search: true,
                    searchicon: 'ace-icon fa fa-search orange',
                    refresh: true,
                    refreshicon: 'ace-icon fa fa-refresh green',
                    view: true,
                    viewicon: 'ace-icon fa fa-search-plus grey'
                },
                {
                    recreateForm: true,
                    mtype: 'PUT',
                    onclickSubmit: function (params, postdata) {
                        params.url = API_URL + 'Update';
                    },
                    beforeShowForm: function (e) {
                        var form = $(e[0]);
                        form.closest('.ui-jqdialog').find('.ui-jqdialog-titlebar').wrapInner('<div class="widget-header" />');
                        styleEditForm(form);
                    }
                },

我的问题是如何在我的 Asp.net Web Api 中检索数据?

    // UPDATE
    [Microsoft.AspNet.Mvc.HttpPut]
    public void Update()
    {
        try
        {
            var item = GetEditedRowDataFromJqGrid(); // how to get item?
            _respository.Update(item);
        }
        catch (Exception e)
        {
            Debug.WriteLine(e.Message);
        }
    }

找到答案:

 // UPDATE
    [Microsoft.AspNet.Mvc.HttpPut("{id}")]
    public void UpdateVendor(string id)
    {
        try
        {
            var item = new Vendor()
            {
                Company = Request.Form["Company"],
                UserName = Request.Form["UserName"]
            };
            _vendorRespository.UpdateVendor(item);
        }
        catch (Exception e)
        {
            Debug.WriteLine(e.Message);
        }
    }