1

Is there a possibility to add a scrollbar into the dropdown list of the treeview ?

When more records are added than in the shown screenshot, some of the fade in columns cannot be seen and I have to scroll down to the end of the tree view list to select these columns.

How can I add a scrollbar into the dropdown menu, without scrolling down to the page but only in the dropdown menu(red bordered) ?

enter image description here

My CSS:

 .dropdown-menu {
    height: 10px;
    overflow-y: auto;
} 

My XML:

<odoo>

    <template id="asset_contacts_addon" name="contacts addon assets" inherit_id="web.assets_backend">
        <xpath expr="." position="inside">
            <link rel="stylesheet" type="text/css" href="/contacts_addon/static/src/css/contacts_addon.css"/>
        </xpath>
    </template>

<record id="contacts_addon_tree_view" model="ir.ui.view">
        <field name="name">view.contacts.addon.tree</field>
        <field name="model">res.partner</field>
        <field name="inherit_id" ref="base.view_partner_tree"/>
        <field name="arch" type="xml">

<p class="dropdown-menu">
    <field name="display_name" position="after">
        <field name="customer_codename" optional="hide"/>
    </field>
     <field name="customer_id_previous" position="after">
        <field name="klm_key" optional="hide"/>
    </field>
</p>

    <field name="customer_codename" position="after">
       <field name="id"/>
     </field>
     <field name="id" position="after">
       <field name="customer_id_previous"/>
     </field>

 </field>
</record>
kayalotta
  • 53
  • 9

1 Answers1

0

One thing you can do is to edit the CSS to set the menu's height and overflow-y in the dropdown-menu class.

.dropdown-menu {
    height: 200px; 
    overflow-y: auto;
}

height is the vertical size of the element. You can set the height to the size you want.

overflow-y is a configuration for vertical scroll of the element. Setting it to auto will often result in what you need.

The result should look something like this.

result

holydragon
  • 6,158
  • 6
  • 39
  • 62
  • Thank you, that looks good. I tried to incorporate the class but I at the moment I can not really figure out how I should assign the different elements to the class. I have several elements in my tree view, but not all are set as optional="hide". When I pass the class to the elements individually it does not work so I tried to put an enclosing tag around the elements which are set optional="hide" . As enclosing tag I used

    tag an put the class in the p tag but I am getting an error now saying that this element can not be found in parent view

    – kayalotta Feb 09 '22 at 09:56
  • @kayalotta Actually, you don't really need to mess with the xml for this particular issue. You can just add a css file and use it. See [this example](https://stackoverflow.com/questions/66903241/how-to-change-size-of-tree-view-without-zoom-odoo-14/67002617#67002617) for how to include css file in your customized module. – holydragon Feb 09 '22 at 10:05
  • I already did that. I edited my question so you can see. What I mean ist how I refer to the class in my XML – kayalotta Feb 09 '22 at 10:33
  • Okay I got it now, the class already exists and I dont need to do changes in the xml. I tried changing auto to scroll but it does not work ? – kayalotta Feb 09 '22 at 12:52
  • @kayalotta First, you need to check if your CSS is applied. I would use inspection tool in the browser to see if the class got the modified attributes. If it is applied properly, the menu should change its display to the one I show in the answer. However, there might be a chance that the added CSS got overwritten by other files (it will show the attributes in strike-through text in the inspection tool). In that case, you need to put [!important](https://www.w3schools.com/css/css_important.asp) to force it to be used. Otherwise (CSS is not applied), you should recheck your module. – holydragon Feb 10 '22 at 01:53
  • My CSS changes were applied after I had to rebuild my test database. However, by restarting the service, the changes I make now are not applied again. What is the reason for this ? – kayalotta Feb 16 '22 at 07:36