JavaScript中的Kendo上传保存对象

时间:2016-01-04 15:07:58

标签: kendo-ui kendo-asp.net-mvc

目前,我的Kendo上传内容如下:

@(Html.Kendo().Upload()
    .Name("UploadPicker")
    .TemplateId("fileTemplate")
    .Async(a => a
        .Save("UploadDepotLogo", "Depot",new {depotID = Model.DepotID})
        .Remove("Remove", "Upload")
        .AutoUpload(false)
    )
)

我需要使用浏览器中的变量而不是depotID的模型,所以我想做这样的事情:

@(Html.Kendo().Upload()
    .Name("UploadPicker")
    .TemplateId("fileTemplate")
    .Async(a => a
        .Save("UploadDepotLogo", "Depot",new {depotID = $("#DepotID").val() })
        .Remove("Remove", "Upload")
        .AutoUpload(false)
    )
 )

这可能吗?

1 个答案:

答案 0 :(得分:1)

以下是您可以做的事情:

@(Html.Kendo().Upload()
    .Name("UploadPicker")
    .TemplateId("fileTemplate")
    .Async(a => a
        .Save("UploadDepotLogo", "Depot")
        .Remove("Remove", "Upload")
        .AutoUpload(false)
    )
    .Events(events => events.Upload("onUpload"))
)

<script type="text/javascript">
    function onUpload(e) {
        e.data = { depotID: $("#DepotID").val() };
    }
</script>