| | 138 | Sometimes it can be convenient to change the displayed text of a status field in the dataTable. This can be done by using the response.s3.dataTableDisplay attribute. First I'll change the model to include a status field: |
| | 139 | {{{ |
| | 140 | #!div style="font-size: 80%" |
| | 141 | change to teh data model: |
| | 142 | {{{#!python |
| | 143 | table = db.define_table(tablename, |
| | 144 | Field("name", required=True, notnull=True), |
| | 145 | Field("path", type="upload", uploadfield=True, required=True, notnull=True, readable=False), |
| | 146 | comments(), |
| | 147 | Field("status", type="integer"), |
| | 148 | migrate=migrate, |
| | 149 | *(s3_timestamp() + s3_uid())) |
| | 150 | }}} |
| | 151 | }}} |
| | 152 | [[BR]] |
| | 153 | [[Image(DataTable_with_Status.png)]] |
| | 154 | [[BR]] |
| | 155 | Now add the code to display a text field depending upon the status: |
| | 156 | {{{ |
| | 157 | #!div style="font-size: 80%" |
| | 158 | Add this to the postp() function of the controller: |
| | 159 | {{{#!python |
| | 160 | values = [dict(col=3, key="1", display=str(T("Uploaded"))), |
| | 161 | dict(col=3, key="2", display=str(T("Imported"))) |
| | 162 | ] |
| | 163 | response.s3.dataTableDisplay = values |
| | 164 | }}} |
| | 165 | }}} |
| | 166 | [[BR]] |
| | 167 | [[Image(DataTable_with_Status_Labels.png)]] |
| | 168 | [[BR]] |