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
we define. This method checks to see if a checkbox for that Person
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
, 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