jqgrid - 在添加/编辑对话框中上传文件

Dra*_*nix 6 javascript jquery jqgrid

我是jqgrid的新手,我通过你的回答学到了很多东西.
现在我遇到了一个问题:我想在向jqgrid添加或修改记录时上传文件?

这是我的代码:

{
    name: 'File',
    index: 'file',
    hidden: true,
    enctype: "multipart/form-data",
    editable: true,
    edittype: 'file',
    editrules: {
        edithidden: true,
        required: true
    },
    formoptions: {
        elmsuffix: '*'
    }
}
Run Code Online (Sandbox Code Playgroud)



但是我在控制器中获得的字段总是为空:(.任何建议
任何人都知道工作示例?
在此提前感谢

更新
我在http://tpeczek.codeplex.com/releases上找到了一个非常好的例子

小智 4

我昨天才开始工作......我的colModel列用于文件上传,

{
    name: 'fileToUpload',
    index: 'customer_id',
    align: 'left',
    editable: true,
    edittype: 'file',
    editoptions: {
        enctype: "multipart/form-data"
    },
    width: 210,
    align: 'center',
    formatter: jgImageFormatter,
    search: false
}
Run Code Online (Sandbox Code Playgroud)

你必须设置afterSubmit:UploadImage.它仅在数据发布并且响应返回后才上传文件.我在这里检查,如果插入是succesfful然后只开始上传其他显示错误.我使用过Jquery Ajax File Uploader.

function UploadImage(response, postdata) {

    var data = $.parseJSON(response.responseText);

    if (data.success == true) {
        if ($("#fileToUpload").val() != "") {
            ajaxFileUpload(data.id);
        }
    }  

    return [data.success, data.message, data.id];

}

function ajaxFileUpload(id) 
{
    $("#loading")
    .ajaxStart(function () {
        $(this).show();
    })
    .ajaxComplete(function () {
        $(this).hide();
    });

    $.ajaxFileUpload
    (
        {
            url: '@Url.Action("UploadImage")',
            secureuri: false,
            fileElementId: 'fileToUpload',
            dataType: 'json',
            data: { id: id },
            success: function (data, status) {

                if (typeof (data.success) != 'undefined') {
                    if (data.success == true) {
                        return;
                    } else {
                        alert(data.message);
                    }
                }
                else {
                    return alert('Failed to upload logo!');
                }
            },
            error: function (data, status, e) {
                return alert('Failed to upload logo!');
            }
        }
    )          }                                                                                            
Run Code Online (Sandbox Code Playgroud)