TWebSiteTable is used to model the table data, resulting from an SQL query, that will be rendered to HTML in Charta Web. It stores the SQL query, the current sort order and the possible edit options.
An instance of TWebSiteTable is rendered to HTML using the function WebSiteTableToHTML. This function executes the SQL query and iterates through the query result outputting an HTML table.
Future plans
There is an obvious overlap between TSQLDatabaseTableModel and the combination of TWebSiteTable and WebSiteTableToHTML: both provide a tabular representation of an SQL query. Moreover, it is unfortunate that a TWebSiteTable is only capable of rendering an SQL query to an HTML table.
In the near future the above problems should be solved by refactoring TWebSiteTable and WebSiteTableToHTML to use a TTableModel. This would have the following advantages:
- Every table model could be rendered to HTML
- Table models provide sorting capabilities so every web site table will have sorting capabilities
- Table models developed for Charta Web will be usable in Charta
- Table models developed for Charta will be usable in Charta Web
Challenges
There are just a few of challenges associated with the above proposal.
Table models can be largeCurrent available table models can represent a huge number of rows. Rendering all rows to HTML will not be sensible. Although not really a problem of the proposed approach, it certainly will be convenient to allow a web site table to view through a small window on the full underlying table model.Table models use integer indexesCurrently table models use integer indexes to reference rows and columns. These integer indexes uniquely identify the cells. Using this identifying property a table selection can be expressed using these integer indexes. However, the current implementation of TWebSiteTable relies on the primary key of a relational table (and it incorrectly assumes that this key is the first column, which is assumed to be integer). In order to allow editing through a TSQLDatabaseTableModel the table control should be able to use table keys to identify rows.