Changes between Version 24 and Version 25 of DeveloperGuidelines/DataTables
- Timestamp:
- 09/05/12 15:58:09 (12 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
DeveloperGuidelines/DataTables
v24 v25 46 46 ) 47 47 else: 48 warehouses = "No warehouses exist"48 warehouses = T("No warehouses exist") 49 49 }}} 50 50 }}} 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 asorting itself.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 and sorting itself. 52 52 53 53 The 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: … … 73 73 # Get the filter and sort instructions from dataTables 74 74 rfields = resource.resolve_selectors(list_fields)[0] 75 (orderby, filter) = S3DataTable.getControlData(rfields, current.request.vars)75 (orderby, filter) = S3DataTable.getControlData(rfields, request.vars) 76 76 # Now set up the resource filter and find out how many row are in the filtered resource 77 77 resource.add_filter(filter) … … 105 105 return warehouse 106 106 else: 107 warehouses = "No warehouses exist"107 warehouses = T("No warehouses exist") 108 108 }}} 109 109 }}} 110 110 Now 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 111 112 == Configuring the table == 112 113 === Adding action buttons === … … 132 133 ] 133 134 rfields = resource.resolve_selectors(list_fields)[0] 134 (orderby, filter) = S3DataTable.getControlData(rfields, current.request.vars)135 (orderby, filter) = S3DataTable.getControlData(rfields, request.vars) 135 136 resource.add_filter(filter) 136 137 filteredrows = resource.count() … … 168 169 return warehouse 169 170 else: 170 warehouses = "No warehouses exist"171 warehouses = T("No warehouses exist") 171 172 }}} 172 173 }}}