Announcement

Collapse
No announcement yet.

How to make panels readOnly on bottomView and sideView based on some condition

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to make panels readOnly on bottomView and sideView based on some condition

    I have gone through the main views/record/detail.js and found that there is a setReadonly() function which seems that it makes the bottomView readOnly and sideView readOnly. i have tried to use it in my custom record/detail view but not working. Is it possible to make bottomView (Panels) & sideView (Panels) READONLY based on ceratin conditon. e.g if i have boolean and if that boolean field is false then make the whole record view with bottomView and sideView readOnly so that the user could only read.

    Anyone who has done this before, i am aware of making the bottomView and sideView disabled but this is not what i want, i need to make panels in both bottomView and sideView readonly when certain conditon is met.

    Thanks
    Last edited by rabii; 10-12-2023, 03:12 PM.
    Rabii
    Web Dev

  • #2
    You can create fields there with 'createField' method. And then use dynamic logic.

    Comment


    • rabii
      rabii commented
      Editing a comment
      will i be able to make panels readOnly if i use dynamic logic ? i have searched through the codebase and couldn't find anything that make a panel readOnly (e.g on account make contacts readOnly no create button and no select).

      I appreciate if you could give any hints how to do it.

      Many thanks and i appreciate your time

  • #3
    You can set only fields read-only. You can't set a panel read-only after initialization. Your panel should have fields (created with createField method). Then the regular dynamic logic will work. Or setFieldReadOnly from the record view.

    Comment


    • #4
      thanks for your reply, i really appreciate it.
      I was thinking that such ability exist hence when i was looking at views/record/detail.js https://github.com/espocrm/espocrm/b...etail.js#L2659
      ​i saw that the setReadOnly function sets the bottomView and the sideView readOnly so i thougt it is possible.

      It would be cool if such capacity is added, setting a panel to readOnly means deactivating the create button and the select option. Very useful when we have use case to archive certain record so that they are still accessible but with no ability to take any further action on both detail view using existing readOnly = true plus such ability applied to both panels on sideview and bottom view.
      Rabii
      Web Dev

      Comment


      • #5
        To make the panels in bottomView and sideView read-only based on a specific condition in your custom record/detail view, you can utilize the existing setReadonly() function. First, ensure that you are correctly importing and calling this function in your custom view. You can check the condition of your boolean field and, if it’s false, invoke setReadonly(true) for both views. Here’s a basic example:

        if (!yourBooleanField) {
        this.setReadonly(true);
        }

        Place this code in the appropriate lifecycle method (like componentDidMount or after the view renders) to ensure it executes when the component is loaded. This approach should effectively make all panels in both views read-only.​

        Comment

        Working...
        X