Hide List/List (small) on condition

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sip63
    Junior Member
    • Oct 2019
    • 16

    Hide List/List (small) on condition

    Hello all,

    I created two entities in EspoCRM : Journey and Accommodation.
    I linked them and added Accommodation as a Relationship Panel in the Journey's model.

    In the Accommodation List (small) view, I setup 4 columns : Name, Size, Capacity and board type.

    I can see the List (Small) relationship panel when I edit a Journey.
    However, I would like to hide the Board type column in the List (small) on a specific condition :

    If Journey -> Type = "Inclusive", I want the column "Board type" to be visible and my user to chose between half board and full board.
    If Journey -> Type = "Full rent", customers are responsible of their own meal and we do not need to have the "Board Type" Value and I would like to hide the column in the relationship panel.

    Is this doable ?
    I went to custom\Espo\Custom\Resources\layouts\Accomodation\ listSmall.json where the view is defined, but there is nothing on the documentation about the different values we can put there.

    Any lead would be much appreciated !

    Best Regards,
    Chris
  • sip63
    Junior Member
    • Oct 2019
    • 16

    #2
    This issue is to hide a List or List (small ) column and not all the list (cannot edit the title)

    Comment

    • Andorxor
      Member
      • May 2019
      • 65

      #3
      You can use the following function to hide/show the column,atleast if the column is sortable
      PHP Code:
      changeBoardtypeVisibility:function()
      {
         if(this.model.get("type")== "Inclusive")
         {
           $('div[data-name="accommodations"]  th a[data-name="boardType"]').parent().show();
           $('div[data-name="accommodations"]  td[data-name="boardType"]').show();
         }
         else
         {
           $('div[data-name="accommodations"]  th a[data-name="boardType"]').parent().hide();
           $('div[data-name="accommodations"]  td[data-name="boardType]').hide();
         }
      } 
      
      You should call it in afterRender und afterSave in the customView for Journey

      Comment

      Working...