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

AsynchUpload in grid example does not work

4 Answers 65 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Atlas
Top achievements
Rank 1
Atlas asked on 16 Aug 2010, 11:39 PM

The following example : http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandradasyncupload/defaultcs.aspx?product=upload
does not appear to work as expected.
If you attempt to upload an invalid file type, you correctly get the error message, but removing the invalid file does not remove the error message, and you can no longer upload a valid file.

Try this:
Click on Add New Record
Select a word doc to upload.
the doc will appear with an red exclamation next to it and an error message appears below.
Remove the file, and attempt to upload a valid gif file, nothing happens. the form continues to think an invalid file is uploaded.

4 Answers, 1 is accepted

Sort by
0
Atlas
Top achievements
Rank 1
answered on 17 Aug 2010, 05:49 PM
Would it be possible for somebody from telerik to respond to this issue and provide a code sample with the fix?
0
T. Tsonev
Telerik team
answered on 19 Aug 2010, 04:08 PM
Hello Nano,

Thank you for reporting this issue. This turned out to be a problem with the example itself.

The uploaded file count is increased in the OnClientFileUploaded event handler and decreased in the OnClientDeleting event handler. The validation error however fires a OnClientValidationFailed event that is not handled at all in the example. As a result we get a wrong file count (-1) when you delete an invalid file.

The problem here is that we don't really have a reliable way of knowing if the user has removed a valid or invalid file. We'll think about this and try to improve the API to include this information.

For the moment, the solution is to remove the OnClientDeleting event handler:
function OnClientDeleting(sender, everntArgs)
{
    uploadedFilesCount--;
}

I hope this helps.

As a token of gratitude for your involvement your Telerik points have been updated.

Sincerely yours,
Tsvetomir Tsonev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Atlas
Top achievements
Rank 1
answered on 19 Aug 2010, 06:01 PM
It doesn't sound like it would matter if the file is invalid or not. if any file is removed, then you should be able to upload another file. If the response to removing an invalid file was the same as removing a valid file there would be no problem.

Is this not an easy fix?

If not the control at this point is pretty useless. I can't release this to our production website if everytime a user uploads an invalid file the form becomes unusable.
0
T. Tsonev
Telerik team
answered on 25 Aug 2010, 02:17 PM
Hello Nano,

By applying the changes I've described you'll achieve exactly that - users will be able to remove invalid files and upload valid files after that.

Here's the updated code:

<script type="text/javascript">
    var uploadedFilesCount = 0;
    var isEditMode;
    function validateRadUpload(source, e)
    {
        // When the RadGrid is in Edit mode the user is not obliged to upload file.
        if (isEditMode == null || isEditMode == undefined)
        {
            e.IsValid = false;
 
            if (uploadedFilesCount > 0)
            {
                e.IsValid = true;
            }
        }
        isEditMode = null;
    }
 
    function OnClientFileUploaded(sender, eventArgs)
    {
        uploadedFilesCount++;
    }
     
</script>

Notice that we're only checking if the user has uploaded at least one valid file. The OnClientFileUploaded will fire for these files only.

I hope this helps.

Sincerely yours,
Tsvetomir Tsonev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Atlas
Top achievements
Rank 1
Answers by
Atlas
Top achievements
Rank 1
T. Tsonev
Telerik team
Share this question
or