Dojo Data Grid – Part 6: Reordering Columns

Column reordering is a useful feature of a grid. If you provide the user the ability to rearrange the columns, you can create less views and grids in the application. There’s no property built into the dojo data grid to allow the user to reorder the columns, but it’s easy to add with a dojo attribute.

Dojo Data Grid Series

Reordering Columns

By default, Dojo Data Grid columns cannot be reordered, but it is an available feature of the dojo grid. All it requires is for the grid to have an attribute of columnReordering set to true. Fortunately, there is a way to add a dojo attribute.

Under All Properties > dojo > dojoAttributes, you can add a dojo attribute, set its name to columnReordering and set it’s value to true.

Grid6_1

This is what the attribute looks like in the page source:

<xe:this.dojoAttributes>
  <xp:dojoAttribute name="columnReordering" value="true"></xp:dojoAttribute>
</xe:this.dojoAttributes>

Now, if I want the lastname column to come before the firstname column in my grid, all I have to do is click on the column header and drag it to the left.

Grid6_2

And now the order has been changed.

Grid6_3

Up Next

In the next post, I’ll show what is required for sorting the grid and preventing sorting of specific columns or specific sort directions.

Advertisements

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: