NOTE: I'm using a ViewModel (MVVM)
please check the image for a better idea...
Any help would be appreciated,
Thanks
7 Answers, 1 is accepted
If I understood your scenario correctly, you want to hook up to an event of the upload control when the item is removed. If that is the case, then you can use the RadUploadItem's Delete event. It will be raised when the upload item is removed by clicking on its delete icon. Is this how an item is deleted in your scenario? Please let me know if that event works for you. Please note that you can attach to it using the EventManager.RegisterClassHandler method.
Best wishes,
Alex Fidanov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
but my RadUploadItem's are dinamically added (like is normal with this kind of component)... and I use a ViewModel class to "control" my UserControl...
The radUpload xaml is:
<telerik:RadUpload
Grid.Column="1" Grid.Row="0"
x:Name="radUpload" Margin="2 0 0 0"
Filter="Text Files (*.txt)|*.txt|Image Files(*.gif;*.jpg;*.jpeg;*.png)|*.gif;*.jpg;*.jpeg;*.png|All Files(*.*)|*.*"
FilterIndex="3" IsMultiselect="True" MaxFileCount="{Binding NumeroMaximoFicheirosUpload}" BufferSize="11000000"
IsAutomaticUpload="False"
OverwriteExistingFiles="True"
UploadServiceUrl="../WebServ/DocumentosCarregados.ashx"
TargetFolder="../Upload"
HorizontalAlignment="Center" VerticalAlignment="Center">
<swi:Interaction.Triggers>
<swi:EventTrigger EventName="FilesSelected">
<esi:CallDataMethod Method="radUpload_FilesSelected" />
</swi:EventTrigger>
<swi:EventTrigger EventName="FileUploadStarting">
<esi:CallDataMethod Method="radUpload_FileUploadStarting" />
</swi:EventTrigger>
<swi:EventTrigger EventName="UploadStarted">
<esi:CallDataMethod Method="radUpload_UploadStarted" />
</swi:EventTrigger>
<swi:EventTrigger EventName="UploadCanceled">
<esi:CallDataMethod Method="radUpload_UploadCanceled" />
</swi:EventTrigger>
<swi:EventTrigger EventName="FileUploaded">
<esi:CallDataMethod Method="radUpload_FileUploaded" />
</swi:EventTrigger>
</swi:Interaction.Triggers>
</telerik:RadUpload>
Can you please explain how to use your former solution? If that solution serves my problem, ofcourse.
Thanks!
I must be able to stop the uploading process in the very beggining of it if I have some bad (custom) validation result in my GridView.. (for visual reference please check the attached file on my first post).
Example: Image that I wanted to show a confirm dialog with "Ok" and "Cancel" when the user clicks the Upload button... how should I proceed if the user clicks "Cancel"? I mean, canceling the Upload without cleaning the items in the RadUpload control?
I've tried to poorly work arround the problem with:
public void radUpload_UploadStarted(object sender, UploadStartedEventArgs e)
{
if (cancelar == true)
{
Collection<
RadUploadSelectedFile
> lista = RU.CurrentSession.SelectedFiles;
RU.CancelUpload();
RU.CurrentSession.SelectedFiles = lista;
}
}
But, the aproach is lame,
RU.CurrentSession.SelectedFiles
is ReadOnly and lista is copied by reference so when
RU.CurrentSession.SelectedFiles
gets empty, lista does also...Can you please help me with these two problems?
You can try to create a CustomRadUpload control that inherits from RadUpload. Then you have to introduce delete event in it which fires every time when the RadUploadItem's Delete event fires. Then you will be able to use this EventTrigger (As I managed to understand this is your main goal).
For the second issue, the approarch you have used isn't bad by design, you only have to improve the implementation: you have to "for-each" SelectedFiles in order fill the "lista" collection before invoking the CancelUpload method. Please let us know if this helped you.
Petar Mladenov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
I don't see how I can get the RadUploadItem's reference as soon as I add files into RadUpload.
At the end of the method:
public void radUpload_FilesSelected(object sender, FilesSelectedEventArgs e)
{ ... } I can't find any RadUploadItem when I call the following method:
void pesquisaRadUploadItems(object sender)
{
IList<RadUploadItem> xpto = ((RadUpload)sender).ChildrenOfType<RadUploadItem>();
}
Only when I fire another radUpload event, like cancel or upload, I am able to find those radUploadItem's, and eventually I would manage to "connect" the Deleted events for each radUploadItem into my custom method.
Before my vacations I should have been sleeping because I couldn't put this to work with the solution I've used now!
Thank you both for your precious help :)