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

Initial files list not working

5 Answers 553 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 09 Aug 2019, 11:41 PM
I am using Kendo Upload for uploading, which works 100%.  But, I just realized the initial file list doesn't work at all.  Can you please provide a working example for .NET core.  I saw in your forum that there was another person who was unsuccessful in an initial file list.  Here is my code:

@(Html.Kendo().Upload()
                      .Name("File")
                      .Async(a => a
                          .AutoUpload(true))
                      .Files(
                      files =>
                      {
                          if (Model.File != null)
                          {
                              files.Add().Name(Model.FileName).Extension(Model.FileExtension).Size((long)Model.FileSize);
                          }
                      }
                      )
                      .Events(e => e.Select("onSelect"))
                      .Multiple(false)
                  )

 

I saw that there was a demo for initial files in mvc but that disappeared in the asp.net core demos.

Thanks


5 Answers, 1 is accepted

Sort by
0
Veselin Tsvetanov
Telerik team
answered on 14 Aug 2019, 03:22 PM
Hello Chris,

Attached you will find a small sample implementing an Upload HTML helper with initial files configured in .Net Core app.

Regards,
Veselin Tsvetanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Chris
Top achievements
Rank 1
answered on 21 Aug 2019, 04:42 PM

I Initially wanted a 'batch' mode upload control that also had an initial files list and I wanted to display thumbnails so the user can see what file is already uploaded when they open the form.  I actually did get this working 100%.  But, unfortunately I had to use async mode with server side functions that never get called, as I did not want to save or remove the image until the form us submitted.  I think this has got to be a standard problem that most developers have with this.  I had to write quite a lot of JS to get it to work the way I want it, and set boolean flags for images to be removed on the server on submit:

@(Html.Kendo().Upload()
.Name("File")
.Async(a => a
.Save("SaveAttachment", "Admin", new { id = Model.Id }) //functions that don't actually get called
.Remove("RemoveAttachment", "Admin", new { id = Model.Id, lang = "en" })
.AutoUpload(false))
.Files(
files =>
{
if (Model.CourseImage != null)
{
files.Add().Name(Model.FileName).Extension(Model.FileExtension).Size((long)Model.FileSize);
}
)
.Events(e => e.Select("cba.onSelect").Remove("cba.onRemove"))
.Multiple(false)
)
0
Veselin Tsvetanov
Telerik team
answered on 26 Aug 2019, 10:09 AM
Hello Chris,

Yes, that is correct, the Upload widget could be configured with initial files only when it is in its Asyc() mode. Having that said, you have correctly approached this case, so you will be able to update the state of the files on submit.

Regards,
Veselin Tsvetanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Chris
Top achievements
Rank 1
answered on 03 Sep 2019, 05:55 PM

For those that are having the same issue, I've created a how to article located here:  Kendo Upload Batch mode.

There is also source code to download, to get started quickly!

 

 

0
Veselin Tsvetanov
Telerik team
answered on 06 Sep 2019, 07:54 AM

Hello Chris,

Thank you for sharing your full implementation with the community. I am sure it would be of great help for other developers too. As a small token of gratitude for your effort, I have just updated your Telerik points.

Regards,
Veselin Tsvetanov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Upload
Asked by
Chris
Top achievements
Rank 1
Answers by
Veselin Tsvetanov
Telerik team
Chris
Top achievements
Rank 1
Share this question
or