7. Paginated Controls
* The QDataGrid Variables
<< * Basic QDataGrid   |   Back to Main   |   * QDataGrid Sorting >>

View Source
will open in a new window
The QDataGrid Variables -- $_ITEM, $_COLUMN, $_CONTROL and $_FORM
As you may have noticed in the first example, we make use of the $_ITEM variable when we render each row's column. There are in fact three special variables used by the QDataGrid: $_ITEM, $_COLUMN, $_CONTROL and $_FORM.

$_ITEM represents a specific row's instance of the array of items you are iterating through. So in our example, the DataSource is an array of Person objects. Therefore, $_ITEM is the specific Person object for the row that we are rendering. $_COLUMN is the QDataGridColumn, $_CONTROL is the QDataGrid itself and $_FORM is the QForm itself.

So in our example, the first column shows the "Row Number", which is basically just the CurrentRowIndex property of the QDataGrid (e.g. $_CONTROL). And the last column's "Full Name" is rendered by the DisplayFullName method we have defined in our ExampleForm (e.g. $_FORM). Note that the DisplayFullName takes in a Person object. Subsequently, in our HTML defintion, we make the call to $_FORM->DisplayFullName passing in $_ITEM.

Finally, note that DisplayFullName is declared as a Public method. This is because DisplayFullName is actually called by the QDataGrid, which only has the rights to call Public methods in your ExampleForm class.
Row Number First Name Last Name Full Name
1 Pop Doe Doe, Pop
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