Changes between Version 24 and Version 25 of DeveloperGuidelines/DataTables


Ignore:
Timestamp:
09/05/12 15:58:09 (12 years ago)
Author:
Fran Boon
Comment:

T, no current. in controllers and typo fix

Legend:

Unmodified
Added
Removed
Modified
  • DeveloperGuidelines/DataTables

    v24 v25  
    4646                                 )
    4747        else:
    48             warehouses = "No warehouses exist"
     48            warehouses = T("No warehouses exist")
    4949   }}}
    5050}}}
    51 This code gets the rows from the resource and passes the data into the S3DataTable html() function the extra parameter of note is the dt_pagination which when set to 'false' will turn server side pagination off. All the data will be sent to the client and !DataTables will manage the filtering a sorting itself.
     51This code gets the rows from the resource and passes the data into the S3DataTable html() function. The extra parameter of note is the dt_pagination which when set to 'false' will turn server side pagination off. All the data will be sent to the client and !DataTables will manage the filtering and sorting itself.
    5252
    5353The next stage is to build a controller that can manage pagination. To do this the controller will need to additionally manage requests from !DataTables for more data.  This can be set up as follows:
     
    7373        # Get the filter and sort instructions from dataTables
    7474        rfields = resource.resolve_selectors(list_fields)[0]
    75         (orderby, filter) = S3DataTable.getControlData(rfields, current.request.vars)
     75        (orderby, filter) = S3DataTable.getControlData(rfields, request.vars)
    7676        # Now set up the resource filter and find out how many row are in the filtered resource
    7777        resource.add_filter(filter)
     
    105105                return warehouse
    106106        else:
    107             warehouses = "No warehouses exist"
     107            warehouses = T("No warehouses exist")
    108108   }}}
    109109}}}
    110110Now the controller needs to manage the two standard request extensions for dataTables: html which is used for the initial table; and aaData which is used for subsequent calls. When the data is prepared for the dataTable it needs to know the total rows in the table and the number of rows that are available after filtering, the filter information is returned from dataTables and the static helper method S3DataTable.getControlData will return the filter and sort information which the user has set up. The json method requires an extra parameter the sEcho which it passes to the server itself. This value just needs to be returned back to the client. '''Note''' that the html call now no longer requires the dt_pagination parameter.
     111
    111112== Configuring the table ==
    112113=== Adding action buttons ===
     
    132133                       ]
    133134        rfields = resource.resolve_selectors(list_fields)[0]
    134         (orderby, filter) = S3DataTable.getControlData(rfields, current.request.vars)
     135        (orderby, filter) = S3DataTable.getControlData(rfields, request.vars)
    135136        resource.add_filter(filter)
    136137        filteredrows = resource.count()
     
    168169                return warehouse
    169170        else:
    170             warehouses = "No warehouses exist"
     171            warehouses = T("No warehouses exist")
    171172   }}}
    172173}}}