Question T22517
Visible to All Users

File Upload - Custom File Previews - Prevent files from being removed in display mode

created 5 days ago (modified 5 days ago)

[Ticket cloned from T22119: Custom Previews for File Upload Questions]

when survey's mode is 'display'.still can delete file or delete button should be hidden,how to fix this issue.

Answers approved by surveyjs Support

created 5 days ago

Hello,
Within your custom component's code, check whether a file upload is isReadOnly or a survey is in read-only mode (SurveyModel.readOnly) and disable the delete file button: View Demo.

Let me know if you have any further questions.

    Show previous comments (4)
    T T
    Transfered Licence Owner 5 days ago

      By the way,I am confused whether the following two variables are equal,Is survey equal question.survey ?

      JavaScript
      const survey = new Survey.Model(dataSource); const isReadOnly = question.isReadOnly || (question.survey && question.survey.readOnly);

        Hello,
        The question.isReadOnly property returns true if a question or its parent is read-only. When you enable a survey's read-only mode, a question is not explicitly set read-only; its parent is a PageModel instance and it's not read-only as well. Therefore, when you render a custom file preview component, you may want to check both these settings: question.isReadOnly and survey.readOnly.

        I hope this information helps. Let me know if you have more questions.

        T T
        Transfered Licence Owner 4 days ago

          I see,Thank