My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions

Issue 204 attachment: totalRows_support.patch (5.2 KB)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
Index: src/org/jmesa/view/html/HtmlSnippetsImpl.java
===================================================================
--- src/org/jmesa/view/html/HtmlSnippetsImpl.java (revision 2295)
+++ src/org/jmesa/view/html/HtmlSnippetsImpl.java Fri Jul 10 19:32:17 BST 2009
@@ -16,13 +16,6 @@
package org.jmesa.view.html;

import static org.apache.commons.lang.StringEscapeUtils.escapeJavaScript;
-import static org.jmesa.view.html.HtmlConstants.ON_INVOKE_ACTION;
-import static org.jmesa.view.html.HtmlConstants.ON_INVOKE_EXPORT_ACTION;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
import org.jmesa.core.CoreContext;
import org.jmesa.limit.Filter;
import org.jmesa.limit.Limit;
@@ -30,12 +23,18 @@
import org.jmesa.limit.Sort;
import org.jmesa.view.ViewUtils;
import org.jmesa.view.component.Column;
+import static org.jmesa.view.html.HtmlConstants.ON_INVOKE_ACTION;
+import static org.jmesa.view.html.HtmlConstants.ON_INVOKE_EXPORT_ACTION;
import org.jmesa.view.html.component.HtmlColumn;
import org.jmesa.view.html.component.HtmlRow;
import org.jmesa.view.html.component.HtmlTable;
import org.jmesa.view.html.toolbar.Toolbar;
import org.jmesa.worksheet.Worksheet;

+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
/**
* @since 2.0
* @author Jeff Johnston
@@ -121,7 +120,7 @@
if (!ViewUtils.isFilterable(columns)) {
return "";
}
-
+
HtmlBuilder html = new HtmlBuilder();
String filterClass = coreContext.getPreference(HtmlConstants.FILTER_CLASS);
html.tr(1).styleClass(filterClass).close();
@@ -242,7 +241,7 @@

/**
* Create a Limit implementation in JavaScript. Will be invoked when the page is loaded.
- *
+ *
* @return The JavaScript Limit.
*/
public String initJavascriptLimit() {
@@ -254,9 +253,9 @@
html.newline();

Limit limit = coreContext.getLimit();
-
+
boolean useDocumentReady = HtmlUtils.useDocumentReadyToInitJavascriptLimit(coreContext);
-
+
if (useDocumentReady) {
html.append("$(document).ready(function(){").newline();
}
@@ -264,6 +263,7 @@
html.tab().append("jQuery.jmesa.addTableFacade('" + limit.getId() + "')").semicolon().newline();

html.tab().append("jQuery.jmesa.setMaxRowsToLimit('" + limit.getId() + "','" + limit.getRowSelect().getMaxRows() + "')").semicolon().newline();
+ html.tab().append("jQuery.jmesa.setTotalRowsToLimit('" + limit.getId() + "','" + limit.getRowSelect().getTotalRows() + "')").semicolon().newline();

for (Sort sort : limit.getSortSet().getSorts()) {
html.tab().append(
@@ -280,12 +280,12 @@
if (worksheet != null && worksheet.isFiltering()) {
html.tab().append("jQuery.jmesa.setFilterToWorksheet('" + limit.getId() + "')").semicolon().newline();
}
-
+
html.tab().append("jQuery.jmesa.setPageToLimit('" + limit.getId() + "','" + limit.getRowSelect().getPage() + "')").semicolon().newline();

html.tab().append("jQuery.jmesa.setOnInvokeAction('" + limit.getId() + "','" + coreContext.getPreference(ON_INVOKE_ACTION) + "')").semicolon().newline();
html.tab().append("jQuery.jmesa.setOnInvokeExportAction('" + limit.getId() + "','" + coreContext.getPreference(ON_INVOKE_EXPORT_ACTION) + "')").semicolon().newline();
-
+
if (useDocumentReady) {
html.append("});").newline();
}
Index: resources/jquery.jmesa.js
===================================================================
--- resources/jquery.jmesa.js (revision 2336)
+++ resources/jquery.jmesa.js Fri Jul 10 19:32:17 BST 2009
@@ -41,6 +41,9 @@
this.getTableFacade(id).limit.setMaxRows(maxRows);
this.setPageToLimit(id, '1');
},
+ setTotalRowsToLimit : function(id, totalRows) {
+ this.getTableFacade(id).limit.setTotalRows(totalRows);
+ },
addSortToLimit : function(id, position, property, order) {
/*First remove the sort if it is set on the limit,
and then set the page back to the first one.*/
@@ -178,8 +181,9 @@
Limit : function (id) {
this.id = id;
this.page = null;
- this.maxRows = null;
+ this.maxRows = null;
+ this.totalRows = null;
- this.sortSet = [];
+ this.sortSet = [];
this.filterSet = [];
this.exportType = null;
},
@@ -224,6 +228,20 @@
setMaxRows : function (maxRows) {
this.maxRows = maxRows;
},
+ getTotalRows : function () {
+ return this.totalRows;
+ },
+ setTotalRows : function (totalRows) {
+ this.totalRows = totalRows;
+ },
+ getTotalPages : function () {
+ if (this.maxRows == 0) return 1;
+ var pages = this.totalRows / this.maxRows;
+ if ((this.totalRows % this.maxRows) > 0) {
+ ++pages;
+ }
+ return pages;
+ },
getSortSet : function () {
return this.sortSet;
},
Powered by Google Project Hosting