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

How do i change the state: State value of uploaded file in success callback function

1 Answer 103 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Arun
Top achievements
Rank 1
Arun asked on 14 Aug 2020, 06:12 AM

Hi,
SuccessHandler is called because of the 200 OK from API. but even if the API is returning 200 OK, still i wanted to change the state manually based on condition.

Once the file is uploaded, Is there a way to change value of state:State variable of interface FileInfo inside onSuccess handler?  

Something like below code, just wants to change the state so it doesn't show file is successfully uploaded message in green in upload control, So doing this is not changing the state, state remains as 3 (success) for all the files -

public onSuccess(e: SuccessEvent) {
  if (e.response.body.isSuccess) {
    // do success stuff
  } else {
    // change all files state to 0 (error in red)
    e.files.forEach(file => {
        file.state = 0;
    });
  }
}
Adam
Top achievements
Rank 1
commented on 30 Nov 2023, 03:18 PM

Arun,

Would you be able to share the answer you received on this?

Thanks

1 Answer, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 17 Aug 2020, 08:27 AM

Hi Arun,

I already answered this question in ticket 1480225which has 72h response time. I recommend continuing our communication here if needed, as the response time is 48h.

Also, try to avoid opening several support threads with the same topic in order to maintain a clean history of your account and provide better support service in general. Thank you for the understanding.

Regards,
Martin
Progress Telerik

Adam
Top achievements
Rank 1
commented on 30 Nov 2023, 03:17 PM

Hello,

Where would I find your answer to this question?

Thanks

Martin
Telerik team
commented on 01 Dec 2023, 08:39 AM

Hi Adam,

The situation is that we fist provide an answer to the questions in a private support thread by then we noticed the public one. Here are details that have been provided there:

`Indeed, the demonstrated implementation relies on private property (state) which is not documented for public use. It could be changed or dropped in a future release of Kendo UI for Angular and this would not be considered a breaking change.

The file state is not changed due to the Angular change detection mechanism. The drawback of this approach is that it needs a setTimeout function called in the success handler when changing the file state programmatically:`

https://stackblitz.com/edit/angular-jv2r9h?file=app%2Fupload.component.ts

The same behavior can be achieved by changing the state on valueChange event, without using setTimeout:

https://stackblitz.com/edit/angular-jv2r9h-wmr8og?file=app%2Fupload.component.ts

Tags
Upload
Asked by
Arun
Top achievements
Rank 1
Answers by
Martin
Telerik team
Share this question
or