Removing the scrollbar thumb from the vertical scroll bar in a Flex DataGrid control

by Peter deHaan on February 13, 2008

in DataGrid

The following example shows how you can remove the scroll thumb from a scroll bar by setting the thumbSkin and verticalScrollBarStyleName styles.

Full code after the jump.

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/02/13/removing-the-scrollbar-thumb-from-the-vertical-scroll-bar-in-a-flex-datagrid-control/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <mx:Style>
        .myCustomScrollBarStyleName {
            thumbSkin: ClassReference(null);
        }
    </mx:Style>

    <mx:Array id="arr">
        <mx:Object c1="Item 1A" c2="Item 1B" />
        <mx:Object c1="Item 2A" c2="Item 2B" />
        <mx:Object c1="Item 3A" c2="Item 3B" />
        <mx:Object c1="Item 4A" c2="Item 4B" />
        <mx:Object c1="Item 5A" c2="Item 5B" />
        <mx:Object c1="Item 6A" c2="Item 6B" />
        <mx:Object c1="Item 7A" c2="Item 7B" />
        <mx:Object c1="Item 8A" c2="Item 8B" />
        <mx:Object c1="Item 9A" c2="Item 9B" />
    </mx:Array>

    <mx:DataGrid id="dataGrid"
            dataProvider="{arr}"
            verticalScrollBarStyleName="myCustomScrollBarStyleName"
            width="300"
            rowCount="4">
        <mx:columns>
            <mx:DataGridColumn dataField="c1"
                    headerText="Column 1:" />
            <mx:DataGridColumn dataField="c2"
                    headerText="Column 2:" />
        </mx:columns>
    </mx:DataGrid>

</mx:Application>

View source is enabled in the following example.

{ 1 comment… read it below or add one }

1 Jonathan October 30, 2009 at 7:13 am

Hi, i need the thumb to remain the same size when I scroll the page, is it possible?

thank u

Reply

Leave a Comment

Sorry, this blog is terrible at eating HTML comments.
If you're pasting any HTML/XML/MXML code, you need to convert your < characters to &lt; and your > characters to &gt; .

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Anti-Spam Protection by WP-SpamFree

Previous post:

Next post: