Changes between Version 10 and Version 11 of DeveloperGuidelines/DataTables


Ignore:
Timestamp:
06/17/11 06:20:31 (14 years ago)
Author:
graeme
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DeveloperGuidelines/DataTables

    v10 v11  
    130130[[Image(DataTable_Plus_Cond_Import_Btn.png)]]
    131131[[BR]]
    132 
     132If you want to add additional restrictions to the automatically provided buttons then try the following code, which has been used to restrict the delete button to records with a certain status
     133{{{
     134    query = (r.table.status == 1) # Status of Pending
     135    rows = db(query).select(r.table.id)
     136    try:
     137        response.s3.actions[1]['restrict'].extend(str(row.id) for row in rows)
     138    except KeyError: # the restrict key doesn't exist
     139        response.s3.actions[1]['restrict'] = [str(row.id) for row in rows]
     140    except IndexError: # the delete buttons doen't exist
     141        pass
     142}}}
    133143=== Changing the displayed text ===
    134144Sometimes 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: