<script id="template" type="text/x-kendo-template">
<div>#= filename #, [#= filesize#]
<span class="menu">
<ul>
<li>#= button_delete #</li>
<li><input class="k-button" value="Insert into text" onclick="insert()"></li>
<li><input class="k-button" value="Copy path to bufer" onclick="copy()"></li>
</ul>
</span>
</div>
</script>
This way i can path either tmplate ID or template object and affect list of files.
Because upload is a very important thing nowadays and usually require more options than just upload.
13 Answers, 1 is accepted
We try to keep the scope of the Upload as narrow as possible. Such advanced UI functionality is better left to dedicated components such as the Grid.
Our suggestion is to hide the default file list (showFileList: false) and use a grid with templated columns as a custom UI.
We don't have a ready example, but everything should be in place to enable this scenario.
I hope this helps.
Tsvetomir Tsonev
the Telerik team
Thank you for your feedback, Peter.
Our initial focus was entirely on uploading files, as the name of the component suggests. We wanted to abstract away the details so people can start using the File API and other technologies as they become available. We now recognize that there's a need for a full-blown file manager component with data-binding, image previews, etc.
I think we can evolve the existing component to fulfill this role. We now have a pretty good idea of what needs to be done thanks to the feedback we received from you and other customers. We're looking forward to doing it as resources become available.
Tsvetomir Tsonev
the Telerik team
For me I am out of this crap. I need something, I wait years? That is not sutable for my projects. Better add some efforts and extend something like Twitter Bootstrap than wait till you finally see the light in the bright idea.
I suggest you open a new user voice item in our feedback portal. Then we could track the user interest in this feature and give it a priority based on that.
Regards,Atanas Korchev
the Telerik team
There's no public method for removing file entries. Using the internal methods is risky, as the implementation is likely to change.
My recommendation is to hide the file entry (<li class="k-file">) and issue an AJAX request to the server, if necessary.
I hope this helps.
Tsvetomir Tsonev
the Telerik team
If you all are just wanting a way to view (i assume pictures) the data you uploaded, this can be done without having to take apart the upload control. Which might result in some sort of weird ugly duckling.
I did read dwhites blog and compared it to my solution that I dreamed up earlier this week for the exact same problem.
However I used Knockout.js to solve this problem instead of relying on MVC.
When you think about it, this isn't a very hard problem to solve. Personally I DON'T feel like the Upload widget should have this sort of preview capability built-in. That would take away from the functionality the name implies. I also feel like it would take away a lot of the creativity (and fun) of building cool stuff.
Alright, getting a preview with Upload is very simple.
$(document).ready(
function
() {
$(
".files"
).kendoUpload({
upload: onUpload,
success: onSuccess,
select: onSelect,
async: {
saveUrl:
"/Document/SaveSingleAsset/@Model.DocumentId"
,
saveField:
"attachments"
,
autoUpload:
true
}
});
});
function
onSuccess(e) {
if
(e !=
null
) {
var
result = e.response;
viewModel.Pictures.push(
new
DocumentPicture(result[0].DocumentId, result[0].DocumentPictureId, result[0].PictureCategory, result[0].Description, result[0].ImageMimeType, result[0].ImageDataBase64));
}
}
function
DocumentPicture(documentId, documentPictureId, pictureCategory, description, mimeType, imageBase64) {
var
self =
this
;
self.DocumentId = ko.observable(documentId);
self.DocumentPictureId = ko.observable(documentPictureId);
self.PictureCategory = ko.observable(pictureCategory);
self.Description = ko.observable(description);
self.ImageMimeType = ko.observable(mimeType);
self.ImageDataBase64 = ko.observable(imageBase64);
}
<
div
class
=
"section"
data-bind
=
"foreach: Pictures"
>
<
div
class
=
"editor-field"
>
<
img
data-bind
=
"attr: { src: 'data:' + ImageMimeType() + ';base64,' + ImageDataBase64() }"
/>
</
div
>
</
div
>
There you go. You could always just pass the URL back from the server when you upload it instead of the Base64 encoded string of binary data.
I see we're nearly 4 YEARS out on this.
I'm trying to do the same thing. Show the user the file they previously uploaded in the SAME CONTEXT. Let them have the remove work like it does when the file is first uploaded.
I attempted to use DWhite's method as described in his blog post, but there have been revision changes to Kendo.
When I come back to a form that has a file uploaded, I would expect to see the same control in the same context. I don't think that any of us here are wanting to massively change the scope of the file upload. If Telerik wants to have a more full-featured file uploader with preview and all of the trimmings in the future, that would be nice.
As I read through the support forum, I'm disheartened by the numerous "we like it that way" responses to customers when they really do have a need for functionality.
Hello Bill,
It is not clear what are you trying to achieve. Could you please elaborate further and describe the scenario?
Regards,Dimiter Madjarov
Telerik