Changes between Version 5 and Version 6 of DeveloperGuidelines/DataTables


Ignore:
Timestamp:
06/10/11 06:51:40 (14 years ago)
Author:
graeme
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DeveloperGuidelines/DataTables

    v5 v6  
    5858
    5959    response.s3.postp = postp
    60     return s3_rest_controller(module, resourcename)  }}}
     60    return s3_rest_controller(module, resourcename)
     61   }}}
    6162}}}
    6263This is sufficient to generate a vanilla dataTable as follows:
     
    8990                              ]
    9091        return output
     92   }}}
    9193}}}
    9294Notice that before the Open and Delete buttons were provided, now they need to be explicitly added.
     
    126128                              ]
    127129        return output
     130   }}}
    128131}}}
    129132The key is the restrict argument that is passed to the Import button. This is set up as a list of record ids that will display the button.
     
    133136
    134137=== Changing the displayed text ===
     138Sometimes 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%"
     141change 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]]
     155Now add the code to display a text field depending upon the status:
     156{{{
     157#!div style="font-size: 80%"
     158Add 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]]
    135169=== Sorting by a selected column ===
     170
    136171=== Filter Rows ===
    137172=== Selecting Rows ===