Introducing cf_sebTable
Over the years, I have had to create countless administrative data tables. Most of them are similar to one another. A few years ago, I saw that my friend, Tim Jackson, had created a custom tag to manage this. I thought the idea was brilliant, but I felt that the implementation could be improved.
The cf_sebTable has the primary purpose of making it easy to create these common tables. In its early incarnation, it looked at database tables directly. Now it pulls data either from a query or from a CFC method.
To display a table of employees from a "qEmployees" query, I could use the following code:
query="qEmployees"
pkfield="EmployeeID"
label="Employee"
editlink="employee-edit.cfm?id=">
<cf_sebColumn dbfield="EmployeeName" label="Name">
<cf_sebColumn dbfield="HireDate" label="Hired" type="date">
</cf_sebTable>
This would produce output something like the following (examples are without skins or styling - see demonstration site for skinning examples):
The "Name" and "Hired" links at the top allow the user to sort the rows by those fields (clicking a second time reverses the sort). Most skins include an indicator of what sort is in effect.
Note the formatting of the edit link: "employee-edit.cfm?id=". The cf_sebTable doesn't know anything about other pages, but it does know the primary key field (because that is a required attribute). It appends the value of the primary key field to the link for each row. So, if the EmployeeID for a record is "3", then the link would be "employee-edit.cfm?id=3".
If I wanted to change the date formatting, I could apply a mask:
query="qEmployees"
pkfield="EmployeeID"
label="Employee"
editlink="employee-edit.cfm?id=">
<cf_sebColumn dbfield="EmployeeName" label="Name">
<cf_sebColumn dbfield="HireDate" label="Hired" type="date" mask="mmmm, yyyy">
</cf_sebTable>
This would change the output:
The sorting, however, would not be effected as it uses the data for sorting, not the formatted output.
The cf_sebTable tag does much more than this, but that will have to wait for another day.
Other topics for the future include:
- Getting data from a CFC
- Saving and Deleting data
- Basic column types
- Custom column types
The sebtags custom tag set is open source and free for any use.
http://www.remotesynthesis.com/post.cfm/Sortable-T...
Sorry if my entry is misleading. The sorting is one very small piece of a much, much larger puzzle here.