Lock columns and Rows in DataGrid for Visibility.

There are two properties in DataGrid where we can lock the visibility of the rows and columns in the DataGrid [here lock the visibility means, which are always visible ,like when scrolling they are not moved to and forth].

The property for ColumnLock is


this takes the value to lock the number of Columns in the Display from left of DataGrid. Here horizontalscrolling locks the columns for visibility.

The property for RowLock is


this also takes the value to lock the number of rows in the Display from top of DataGrid. Here verticalscrolling locks the rows for visibility.

code Example:

<mx:DataGrid x=”277″ y=”331″ id=”dg” dataProvider=”{xml}”

lockedColumnCount=”3″ height=”96″ horizontalScrollPolicy=”on”

verticalScrollPolicy=”on” width=”397″>


<mx:DataGridColumn headerText=”Sl.No” dataField=”slno”/>

<mx:DataGridColumn headerText=”Product Name” dataField=”PNAME”/>

<mx:DataGridColumn headerText=”Pro ID” dataField=”PID”/>

<mx:DataGridColumn headerText=”Cat ID” dataField=”CAT_ID”/>

<mx:DataGridColumn headerText=”Cat Name” dataField=”CATEGORY”/>



The below image shows the locking of two columns.

Enjoy the code !, happy Flexing.


10 Responses to Lock columns and Rows in DataGrid for Visibility.

  1. Vimal says:

    Is it posible to lock the colums and rows dynamically? I have a requirement, the user must be able to select the lockcolumn count from a list .

  2. kumargandhi says:

    yes it is possible , dynamically , your logic will work.


  3. Siva says:

    is it possible to lock a row in an Advanced DataGrid in a tree mode ?

  4. jay says:

    is it possible to disable sorting for only the lockedRowCount in datagrid

  5. Frank says:

    does this possibility also exists for a grid ?

    • kumargandhi says:

      No this possibility does not exit for Grid.Grid is different from that of the DataGrid.Grid is similar to Table Tag in Html [to arrange components and align them].


  6. Mark says:

    May I disable the highlighted vertical line when I use “lockedColumnCount”? I need a normal vertical line showed.

    I try ” dg.setStyle(“verticalGridLineColor”, #cccccc);” but it doesn’t affect it.



    • kumargandhi says:

      verticalGridLineColor is for setting “The color of the vertical grid lines”, but for locked columns DataGrid uses a skin to draw the locked columns vertical/horizontal lines.so you can use the style properties “verticalLockedSeparatorSkin”,”horizontalLockedSeparatorSkin” to define your skins. (didn’t try it personally but sure it will work)


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: