8. Advanced Controls Manipulation
* Creating Checkboxes in a Datagrid
<< Previous   |   Back to Main   |   * Datagrid with Inline Editing >>

View Source
will open in a new window
Dynamically Creating QControls in a QDataGrid
In this example we will take our Paginated QDataGrid, and add a column which has a "Select" checkbox. When clicking the checkbox, a server action will update the response label to say who has been selected or deselected.

To get this to work, we added a fourth column to put the checkbox. In the HTML of that column, we make a call to a new chkSelected_Render method which we define. This method checks to see if a checkbox for that Person has already been created (and if not, it will then create one). The method then returns the rendered string for that checkbox.

Also, on the column object, itself, we need to make sure to set the HtmlEntities to false, so that the HTML of the checkbox doesn't get escaped.

And finally, we define a QClickEvent server action for the checkboxes which will call the chkSelected_Click method to actually perform the action. In order to let the chkSelected_Click method know which Person we just selected or deselected, we set the ActionParameter of each checkbox to the ID of the Person.

Previous|12|Next Results: Viewing items 1-10 of 12.
Person ID First Name Last Name Sorted Select Person
9 Linda Brady
11 Brett Carlisle
1 Pop Doe
4 Mike Ho
8 Samantha Jones
12 Jacob Pratt
2 Kendall Public
3 Ben Robinson
5 Alex Smith
10 Jennifer Smith