I would like to use the tag helper, but I cannot set the initial files like
<files>@Html.Raw(Model.InitialFiles)</files>
I am only able to set them as static HTML list, i.e.
<files><file name="dummy" size="1024" extension=".ext"/></files>
(https://docs.telerik.com/aspnet-core/tag-helpers/editors/upload/overview)
Is it possible to use the tag helper when the file list would be obtained from a model? And how?
5 Answers, 1 is accepted
Thank you for reporting the issue.
I have logged it as a bug and we will do our best to fix it as soon as possible. If you observe any other issue or you have further questions please let me know.
Regards,
Plamen
Progress Telerik
Yes, this is not working for me also. The statement:
.Files(
files =>
{
files.Add().Name("NAME1").Extension(".jpg").Size(1234);
}
)
doesn't work. why not? Please provide a complete working example with taghelper. Thanks
An exemplary .Files configuration of the Upload's taghelper is shown below:
<
kendo-upload
drop-zone
=
"drop-zone1"
name
=
"files"
>
<
async
save-url
=
"save"
/>
<
files
>
@foreach (var f in Model)
{
<
file
name
=
"@f.Name"
extension
=
"@f.Extension"
size
=
"@f.Size"
></
file
>
}
</
files
>
</
kendo-upload
>
The index action returning the viewmodel:
IList<UploadInitialFile> initialFiles =
new
List<UploadInitialFile>();
public
IActionResult Index()
{
UploadInitialFile file1 =
new
UploadInitialFile(
"file1"
, 1200000,
".jpg"
);
UploadInitialFile file2 =
new
UploadInitialFile(
"file2"
, 1400000,
".png"
);
initialFiles.Add(file1);
initialFiles.Add(file2);
return
View(initialFiles);
}
The view model:
public
class
UploadInitialFile
{
public
string
Name {
get
;
set
; }
public
long
Size {
get
;
set
; }
public
string
Extension {
get
;
set
; }
public
UploadInitialFile(
string
name,
long
size,
string
extension)
{
this
.Name = name;
this
.Size = size;
this
.Extension = extension;
}
}
Regards,
Ivan Danchev
Progress Telerik
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!
Chris,
Thank you for sharing your approach with the community. I am sure it would be helpful to anyone facing a similar scenario.
Regards,
Ivan Danchev
Progress Telerik