Changes between Version 2 and Version 3 of DeveloperGuidelines/DataTables


Ignore:
Timestamp:
06/10/11 04:36:37 (14 years ago)
Author:
graeme
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DeveloperGuidelines/DataTables

    v2 v3  
    1919|| dataTableStyleWarning || This can be used to give a style to represent a warning condition for the row || list of ids to apply this style || This adds the class 'warning' to the tr element ||
    2020
    21 == Example ==
     21== Examples ==
     22The following example illustrate how to implement dataTables in your code. It uses the following base code:
     23{{{
     24#!div style="font-size: 80%"
     25Model code snippet:
     26  {{{#!python
     27    resourcename = "csv"
     28    tablename = module + "_" + resourcename
     29    table = db.define_table(tablename,
     30                            Field("name", required=True, notnull=True),
     31                            Field("path", type="upload", uploadfield=True, required=True, notnull=True),
     32                            comments(),
     33                            migrate=migrate,
     34                            *(s3_timestamp() + s3_uid()))
     35
     36    table.name.comment = DIV(_class = "tooltip",
     37                             _title = T("Name") + "|" + T("Enter a name of the CSV you are uploading."))
     38
     39    s3.crud_strings[tablename]= Storage(
     40            title_create = T("Upload a CSV file"),
     41            title_list = T("List of CSV files uploaded"),
     42            label_list_button = T("List of CSV files"),
     43            )
     44  }}}
     45Controller code snippet:
     46  {{{#!python
     47def csv():
     48
     49    """ RESTful Controller """
     50
     51    module = "importer"
     52    resourcename = "csv"
     53    tablename = module + "_" + resourcename
     54    table = db[tablename]
     55
     56    def postp(r, output):
     57        return output
     58
     59    response.s3.postp = postp
     60    return s3_rest_controller(module, resourcename)  }}}
     61}}}
     62This is sufficient to generate a vanilla dataTable as follows:
     63[[Image()]]
    2264=== Adding Buttons ===
    2365=== Adding Buttons conditionally ===