xpages hiding/showing fields based on a combobox value

后端 未结 3 2197
灰色年华
灰色年华 2020-12-21 14:34

I\'m using a with 10 containing numerous fields components.

There is a principal combobox wh

3条回答
  •  暖寄归人
    2020-12-21 15:00

    I would turn it around. Let the labels and fields ask the combobox if they should be rendered or not. Let the combobox's onchange event initiate a partial refresh of a panel which includes all fields you want to show/hide.

    If your >50 fields are all on one place you can frame them with a panel and set the rendered property there.

    If your combobox is bound to a viewScope variable the rendered property of fields/labels would be

    rendered="#{javascript:viewScope.tipcontractcv1 == 'Vanzare-Cumparare'}"
    

    or if it is bound to a document field then

    rendered="#{javascript:document1.getItemValueString('txt_tipcontractcv1') === 'Vanzare-Cumparare'}"
    

    Update:

    Based on your code in your answer https://stackoverflow.com/a/25636661/2065611 take the following steps so get it to work with the Dojo Tab Container:

    1.

    Put the labels and fields in panels which do have an id but don't have a rendered attribute

    
           
             
        
        ... other label and fields ...
    
    

    You can create other panels "panel2", "panel3", ... too. They can be placed in different djTabPanes.

    2.

    Change the onchange event of your combobox and execute client side code to refresh the panels

                
                    
                
    

    3.

    You can optimize your code if you put labels and fields with the same rendered attribute together into an additional panel

    
        
               
            ... other label and fields ...
        
    
    

提交回复
热议问题