Kendo网格行中的Kendo Upload添加了行

时间:2017-01-10 11:35:37

标签: razor kendo-ui

我在我的应用程序中使用Kendo()网格,它与模型绑定。 我想在Grid中为每一行提供上传控件。请看剃刀视图设计如下:

<div id="processDetailGrid"></div>
 var processDetailGrid
        , processDetailDataSource
        , processDetailToolbar
        , projectComboBox;  
 $(function () {
   ProcessDetailToolbar = $("#processDetailToolbar").kendoToolBar({items: [{ id: "processDetailAdd", type: "button", spriteCssClass: "fa fa-plus-square", text: "Add", overflow: "never", click: processDetailAdd }]}).data("kendoToolBar");
function processDetailAdd() {
            processDetailGrid.addRow();}

processDetailGrid = $("#processDetailGrid").kendoGrid({
            dataSource: processDetailDataSource,
            height: '98%',
            selectable: "cell",
            resizable: true,
            reorderable: true,
            columnMenu: true,
            editable: false,
            columns: [

                 {
                     field: "SoftwareUpLoad",
                     title: "@Resource.Field_SoftwareUpLoad",
                     template: kendo.template($("#template").html()),
                    // template: '#= SoftwareUpLoad==""?"<input type=\'file\' show=\'0\' name=\'files\'  />":"<a class=\'k-button\' href=\'GetFiles?key=SoftwareUpLoad\'>Download</a>"#',
                     width: 300
                 },
                 {
                     field: "CutterCode",
                     title: "CutterCode",
                     width: 200
                 }

            ],
            dataBound: function (e) {
                var grid = this;
                var firstItem = this.dataSource.view()[0];


                    this.tbody.find("input[name=files][show=0]").kendoUpload({
                        multiple: false,
                        async: {
                            saveUrl: 'save',
                            removeUrl: "remove",
                            autoUpload: true
                        },
                        validation: {

                            allowedExtensions: [".pdf"]
                        },
                        upload: function (e) {
                            var item = grid.dataItem(this.element.closest("tr"));
                            var id = BillId;
                            this.element.closest(".k-button").addClass("k-state-disabled");
                            this.element.closest(".k-button").find("input[name=files]").attr("show", "1");

                            e.data = { id: id, Operation: item.OperationNO };
                        },
                        remove: function (e) {
                            var item = grid.dataItem(this.element.closest("tr"));
                            var id = BillId;
                            this.element.closest(".k-button").removeClass("k-state-disabled");
                            e.data = { id: id, Operation: item.OperationNO };
                        },
                        success: function (e) {
                            var FileName = e.response.FileName;

                            var item = grid.dataItem(this.element.closest("tr"));
                            item.FileName = FileName;

                            item.dirty = false;
                        }
                    });
            }

        }).data("kendoGrid");

}) 

在网格数据行我上传数据,点击新行按钮,上传的数据会自动清空,但我不是那个,我想问怎么办?

0 个答案:

没有答案