Understanding how columns are indexed and positioned.

The SRP ReportTable Control provides a great deal of power to the end user. In addition to sorting, users can reposition columns and even group by one or more columns' unique values. Since columns can change visual positions, it's imperative that the programmer be able to interact with columns without having to worry about the changes made by the user.

Indexes vs. Position

Column indexes are established when setting the ColumnList property. The second column in the ColumnList is column two, and it will always be column two throughout the life of the table. Even if the user moves the column, hides it, or groups by it, you will always pass 2 to all the column properties to interact with it.

At the moment you set ColumnList, the columns index and position are the same. Initially, column two is at position two. When the user moves the column to the left, its position becomes one but it is still column two. This terminology will be used throughout the documentation. Position refers to its position as seen by the user. Index refers to the columns original index when first set.

Column Order

When you read the ColumnList property, it will be returned in the same order that you set it. In order to get the columns' current positions, you have two options. Use the ColumnOrder property to get an @FM delimited array of the columns' indexes in the left-to-right order in which they appear to the user. For example, if ColumnOrder returns 1:@FM:3:@FM:2, then column 1 is in position 1, column 3 is in position 2, and column 2 is in position 3. If you just want the position of a single column, use the ColumnPosition property instead.

Sometimes you may need to programmatically move a column. For example, you may want to restore a previously known column order for convenience. Both ColumnOrder and ColumnPosition are read only. To move a column, use the MoveColumn method. It can only move one column at a time, but a simple loop will allow you to move all the column to the desired positions.

  • No labels