Search code examples
file-uploaddatagridasp.net-core-mvcdevextreme

DevExtreme - cell with FileUpload


Is there any possibility to create DataGrid cell with FileUpload associated with row.

For example I have database with records and I want to have a possibility to attach files to selected records.

Is someone know how to do that and can share with me ;)

Thanks a lot for your help :D


Solution

  • Do you mean something like this:

    A simple demo:

    <div class="demo-container">
        <div id="gridContainer"></div>
    </div>
    
    
    <script>
        $(function () {
            var customers = [{
                "ID": 1,
                "CompanyName": "Premier Buy",
                "Address": "7601 Penn Avenue South",
    
            }, {
                "ID": 2,
                "CompanyName": "ElectrixMax",
                "Address": "263 Shuman Blvd",
    
            }, {
                "ID": 3,
                "CompanyName": "Video Emporium",
                "Address": "1201 Elm Street",
    
            }]
            $("#gridContainer").dxDataGrid({
                dataSource: customers,
                showBorders: true,
                columns: ["CompanyName", "Address", {
                    dataField: "COLUNIQID",
                    alignment: 'center',
                    caption: "Actions",
                    cellTemplate: function (container, options) {
                        $('<input type="file" />')
                            .on('change', function () {
                                //do the upload here
                                
                            })  
                            .appendTo(container);
                    }
                }]
            });
    
        });
    </script>
    

    enter image description here