Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Add javascript to ticket reports tables so that clicking on column headers causes the table to be sorted by that header. Clicking again reverses the sort order. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | click-to-sort-reports |
| Files: | files | file ages | folders |
| SHA1: |
c43da4fcd14505533961bd8b5b07747e |
| User & Date: | drh 2012-11-30 15:07:50.727 |
Context
|
2012-11-30
| ||
| 15:16 | Add javascript to ticket reports tables so that clicking on column headers causes the table to be sorted by that header. Clicking again reverses the sort order. ... (check-in: 20f17aeb05 user: drh tags: trunk) | |
| 15:07 | Add javascript to ticket reports tables so that clicking on column headers causes the table to be sorted by that header. Clicking again reverses the sort order. ... (Closed-Leaf check-in: c43da4fcd1 user: drh tags: click-to-sort-reports) | |
| 14:09 | fix testcase ... (check-in: e08073d333 user: jan.nijtmans tags: trunk) | |
Changes
Changes to src/report.c.
| ︙ | ︙ | |||
692 693 694 695 696 697 698 |
pState->nCol++;
}
}
}
/* The first time this routine is called, output a table header
*/
| | | 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 |
pState->nCol++;
}
}
}
/* The first time this routine is called, output a table header
*/
@ <thead><tr>
zTid = 0;
for(i=0; i<nArg; i++){
char *zName = azName[i];
if( i==pState->iBg ) continue;
if( pState->iNewRow>=0 && i>=pState->iNewRow ){
if( g.perm.Write && zTid ){
@ <th> </th>
|
| ︙ | ︙ | |||
714 715 716 717 718 719 720 |
}
@ <th>%h(zName)</th>
}
}
if( g.perm.Write && zTid ){
@ <th> </th>
}
| | | 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 |
}
@ <th>%h(zName)</th>
}
}
if( g.perm.Write && zTid ){
@ <th> </th>
}
@ </tr></thead><tbody>
}
if( azArg==0 ){
@ <tr><td colspan="%d(pState->nCol)">
@ <i>No records match the report criteria</i>
@ </td></tr>
return 0;
}
|
| ︙ | ︙ | |||
912 913 914 915 916 917 918 919 920 921 922 923 924 925 |
}
}
rc = sqlite3_finalize(pStmt);
fossil_free(azVals);
return rc;
}
/*
** WEBPAGE: /rptview
**
** Generate a report. The rn query parameter is the report number
** corresponding to REPORTFMT.RN. If the tablist query parameter exists,
** then the output consists of lines of tab-separated fields instead of
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 |
}
}
rc = sqlite3_finalize(pStmt);
fossil_free(azVals);
return rc;
}
/*
** Output Javascript code that will enables sorting of the table with
** the id zTableId by clicking.
**
** The javascript is derived from:
**
** http://www.webtoolkit.info/sortable-html-table.html
**
*/
static void output_table_sorting_javascript(const char *zTableId){
@ <script>
@ function SortableTable(tableEl){
@ this.tbody = tableEl.getElementsByTagName('tbody');
@ this.sort = function (cell) {
@ var column = cell.cellIndex;
@ this.sortIndex = column;
@ var newRows = new Array();
@ for (j = 0; j < this.tbody[0].rows.length; j++) {
@ newRows[j] = this.tbody[0].rows[j];
@ }
@ newRows.sort(this.sortText);
@ if (cell.getAttribute("sortdir") == 'down') {
@ newRows.reverse();
@ cell.setAttribute('sortdir','up');
@ } else {
@ cell.setAttribute('sortdir','down');
@ }
@ for (i=0;i<newRows.length;i++) {
@ this.tbody[0].appendChild(newRows[i]);
@ }
@ }
@ this.sortText = function(a,b) {
@ var i = thisObject.sortIndex;
@ aa = a.cells[i].textContent.replace(/^\W+/,'').toLowerCase();
@ bb = b.cells[i].textContent.replace(/^\W+/,'').toLowerCase();
@ if(aa==bb) return 0;
@ if(aa<bb) return -1;
@ return 1;
@ }
@ var thisObject = this;
@ var x = tableEl.getElementsByTagName('thead');
@ if(!(this.tbody && this.tbody[0].rows && this.tbody[0].rows.length>0)){
@ return;
@ }
@ if(x && x[0].rows && x[0].rows.length > 0) {
@ var sortRow = x[0].rows[0];
@ } else {
@ return;
@ }
@ for (var i=0; i<sortRow.cells.length; i++) {
@ sortRow.cells[i].sTable = this;
@ sortRow.cells[i].onclick = function () {
@ this.sTable.sort(this);
@ return false;
@ }
@ }
@ }
@ var t = new SortableTable(gebi("%s(zTableId)"));
@ </script>
}
/*
** WEBPAGE: /rptview
**
** Generate a report. The rn query parameter is the report number
** corresponding to REPORTFMT.RN. If the tablist query parameter exists,
** then the output consists of lines of tab-separated fields instead of
|
| ︙ | ︙ | |||
990 991 992 993 994 995 996 |
if( g.perm.NewTkt ){
style_submenu_element("New Ticket", "Create a new ticket",
"%s/tktnew", g.zTop);
}
style_header(zTitle);
output_color_key(zClrKey, 1,
"border=\"0\" cellpadding=\"3\" cellspacing=\"0\" class=\"report\"");
| | > | > | 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 |
if( g.perm.NewTkt ){
style_submenu_element("New Ticket", "Create a new ticket",
"%s/tktnew", g.zTop);
}
style_header(zTitle);
output_color_key(zClrKey, 1,
"border=\"0\" cellpadding=\"3\" cellspacing=\"0\" class=\"report\"");
@ <table border="1" cellpadding="2" cellspacing="0" class="report"
@ id="reportTable">
sState.rn = rn;
sState.nCount = 0;
report_restrict_sql(&zErr1);
sqlite3_exec_readonly(g.db, zSql, generate_html, &sState, &zErr2);
report_unrestrict_sql();
@ </tbody></table>
if( zErr1 ){
@ <p class="reportError">Error: %h(zErr1)</p>
}else if( zErr2 ){
@ <p class="reportError">Error: %h(zErr2)</p>
}
output_table_sorting_javascript("reportTable");
style_footer();
}else{
report_restrict_sql(&zErr1);
sqlite3_exec_readonly(g.db, zSql, output_tab_separated, &count, &zErr2);
report_unrestrict_sql();
cgi_set_content_type("text/plain");
}
|
| ︙ | ︙ |