Creating a QDataGrid with Inline Editing

Using the techniques for dynamically creating controls and utilizing the AJAX features in QCubed, we update our Person datagrid to include functionality for inline editing.

We must first add a $intEditPersonId in the QForm to keep track of which Person (if any) we are currently editing. We then must define the First and Last Name QTextBoxes, as well as Save and Cancel QButtons. Note that we only need to define one of each, because only one Person can be edited at a time. The textboxes have QEscapeKeyEvents defined on them to perform a "Cancel", and the "Save" button is set to be a PrimaryButton. This allows the textboxes to be sensitive to the Enter and Escape keys for saving and cancelling, respectively.

We also define render methods for each of the columns to properly display either the name or the QTextBox, depending on the row we are rendering and which Person we are editing.

And finally, we add a btnNew at the bottom to allow the user to create new Person objects. If they want to create a new person, the $intEditPersonId is set to -1, and we get the datagrid to basically act as if it's editing a blank person.

Person ID Sorted First Name Last Name Edit
2 ffgfEmeri sadas Smith
3 Ben Anzolaasdfd
4 dany DFGDSG
5 Public BLA BLA BLA
6 Caro Smith
7 Karen Wolfeasdsa
8 Zucker Berg
9 Linda Dss ddfd
10 Jennifer S
11 Breteny Carlisle
12 89i7 Pratt
18 Test Test
19 me me
20 twenty lines
21 poku pokus
22 Mahub baub
23 Sha Moh
24 dsfds ooo
35 xcvxc sdfsdf
36 isamar ,m,m.,m
37 KAJsdhh aksjdjj
38 vvv1 1vvvv
54 test test
55 lolo asdasf
56 dsdas dasdasd
57 5454 htrytrytr
63 fff fff
69 Kleand Test
85 ffd fdfgfd
86 dfgdf bfr
87 kk kk
89 j k
90 njjj jj
101 dgd dfh
107 dfcfg ghghgh
113 bvmvmbv ckggfkgfkfg
119 fsdgf dfgdgd
130 gv ddds
131 dsdsdsdsdsdss dsds
137 lkkkkkkk jhhhhhhh
138 aaa aa
144 dfbdbd dfbdbd
145 xcxc shaa
146 555 555
147 ssss sssss
153 Juancho Talarga
169 test test
170 test2 test2
171 ffrf rrrr
172 hkhj .m.,m
193 ranny sanchez
194 ewrwerw werwerwerwerwerwer
196 cy mg
197 Alan Moh
198 Gool Gool
199 5454 5454
215 sadsadf dsfdsf
216 ZxZx ZXZX
222 narendra 123
238 23 5665
239 1 2
245 d d
246 u ivan
248 89985 jasdhklfsssssssssssssssssssssssssssssssssssssssssd
254 sdfsafds r34sdfasfsdf
255 dgfds sdfsd
256 this tgfdse
262 ASA sds