The QDataGrid Row Actions

Adding actions to data grid row is very similar to adding actions to any other QControl. In a QControl, we use the AddAction() method for adding actions. For data grid rows we'll use QDataGrid's AddRowAction() method exactly the same way. In a QControl, we use the ActionParameter property to pass parameters to the action. For the data grid, we'll use the QDataGrid's RowActionParameterHtml property to pass parameters to the row actions. In fact, the RowActionParameterHtml uses the same technique and the same variables as seen in the QDataGrid variables example.

In the example below, we'll make the data grid rows respond to mouse movements and to clicks anywhere in the row. To achieve it, we'll need to add 3 actions to our data grid: one for mouse over, one for mouse out, and one for click. We'll use the QCssClassAction action to add a CSS class when the mouse is over a row or goes out of the row. We'll use a standard QAjaxAction for the click handler to call our QForm's method which will simply tell us which row we just clicked on.
Row # First Name Last Name Full Name
1 John Doe Doe, John
2 Kendall Public Public, Kendall
3 Ben Robinson Robinson, Ben
4 Mike Ho Ho, Mike
5 Alex Smith Smith, Alex
6 Wendy Smith Smith, Wendy
7 Karen Wolfe Wolfe, Karen
8 Samantha Jones Jones, Samantha
9 Linda Brady Brady, Linda
10 Jennifer Smith Smith, Jennifer
11 Brett Carlisle Carlisle, Brett
12 Jacob Pratt Pratt, Jacob