This is a migrated thread and some comments may be shown as answers.

Uploaded File List to datasource

2 Answers 281 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Troy Clemons
Top achievements
Rank 1
Troy Clemons asked on 22 Apr 2014, 01:23 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Dimiter Madjarov
Telerik team
answered on 22 Apr 2014, 02:41 PM
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!
 
0
Troy Clemons
Top achievements
Rank 1
answered on 22 Apr 2014, 04:10 PM
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.
Tags
Upload
Asked by
Troy Clemons
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Troy Clemons
Top achievements
Rank 1
Share this question
or