Uploaded File List to datasource

3 posts, 1 answers
  1. Troy Clemons
    Troy Clemons avatar
    69 posts
    Member since:
    Apr 2010

    Posted 22 Apr 2014 Link to this post

    is there a way to get the list of uploaded files added to a datasource.
    Here is my attempt, my alert box returns the appropriate data, but for some reason the grid is not displaying the returned data.
    $("#files").kendoUpload({
                        async: {
                            saveUrl: "upload.aspx",
                            autoUpload: true,
                            batch: false
                        },
                        files: files,
                        upload: function (e) {
                            filecount = filecount + 1;
                            $.map(e.files, function (file) {
                                var info = file.name;
                                var filesize = file.size
                                var upGrid = $('#upfilelist').data("kendoGrid");
                                var dataSources = UFSource;
                                var newrecord = { ufid: compups, FileName: info, FileSize: filesize };
                                //alert(compups +'_'+ filename + '_' + filesize);
                                dataSources.insert(newrecord);
                                upGrid.dataSource = dataSources;
                            });
                        },
                        complete: function (e) {
                            //filecount = 0;
                            compups = compups + 1
                                                                            
                            document.getElementById("FileCount").innerText = 'Files Uploaded: ' + filecount;
                            $(".k-upload-files.k-reset").find("li").parent().remove();
                        },
                        showFileList: true
                         
                    });









  2. Answer
    Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2159 posts

    Posted 22 Apr 2014 Link to this post

    Hello Troy,


    Assuming that the item is added correctly to the dataSource (insert will place it on index 0, when the index is not specified), you could then use the setDataSource method of the Grid in order to update it correctly.
    E.g.
    dataSources.insert(newrecord);
    upGrid.setDataSource(dataSources);

    Let me know if this was the reason for the issue or I could assist you further on this topic.

    Regards,
    Dimiter Madjarov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
  4. Troy Clemons
    Troy Clemons avatar
    69 posts
    Member since:
    Apr 2010

    Posted 22 Apr 2014 Link to this post

    works like a charm, I had setDataSource in there before and it gave me an error.

    Note to self and other coders. Case Sensitivity. setdataSource <> setDataSource :)

    thank you.
Back to Top