8. Advanced Controls Manipulation
* Dynamically Creating Controls in Datagrid Rows
<< Previous
|
Back to Main
|
* The Easy Way to Add a Checkbox Column to a Datagrid >>
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
|
1
2
|
Next
Results:
Viewing items 1-10 of 19.
Person ID
First Name
Last Name
Select Person
3
Ben
5665564
Select
1
kavita 2
arulyfred
Select
9
Linda
Brady
Select
11
Brett
Carlisle j
Select
4
Mike
Ho
Select
14
sdhgfhsdg
jai
Select
17
good
job
Select
16
Nice
Job
Select
8
Samantha
Jones
Select
12
Jacob
Pratt
Select