Showing posts with label DevExpress. Show all posts
Showing posts with label DevExpress. Show all posts

DevExpress ASPxGridView CommandColumn Built-in and Custom Button Sort Order Solution

DevExpress provides a number of useful controls that I've used for a variety of projects. I recently encountered an annoyance with the ASPxGridView controls Command Column. The Command Column provides a fixed set of out of the box buttons (Edit, New, Delete, Select) and the ability to specify custom buttons. In my example below I am using the built-in Delete button, displayed first, and four custom buttons, one of which, displayed second, triggers navigation to a custom editor page. There isn't a way to change this ordering due to DevExpresses implementation of the command column ordering.


Buttons are rendered in the fixed order (Edit, New, Delete, Select, [Custom]) within DevExpress's code,  GridViewTableCommandCell.CreateControlHierarchy(). This is fine if you use all of the built-in features of the DevExpress control however if you were to provide a custom button(s) as I have, it's not possible server side to force a custom button to be displayed before or intermingled with a built-in button.

The solution is to handle this client side with a jquery function. There are many possible ways to go about sorting the command column but I wanted to just ensure the if the default delete button was used it would always display last in the command column.