| Issue 204: | RFE: Add totalRows to javascript limit class | |
| 1 person starred this issue and may be notified of changes. | Back to list |
Motive: I needed to add a validation not allowing the user to call export when the data would have more than X rows. For this, I needed the total rows in the table contained and this wasn't available anywhere. Patch: - Add a variable totalRows and access methods to the javascript Limit class. - Add java support code to set the variable. - For completeness, also added a method Limit.getTotalPages() that works like the java code in HtmlUtils.
Jul 11, 2009
Project Member
#1
jeff.johnston.mn@gmail.com
Jul 13, 2009
I like the feature but this code will not work when using AJAX. The reason AJAX works with JMesa is that the JavaScript Limit on the client has all the correct values and is never updated by the server. So as a person sorts, filters and pages the client JavaScript Limit is updated and then passed to the server. The totalRows is something that is calculated on the server and would have to be sent back to the client for this now. So instead of just returning the HTML we would have to return a more complex object to return the HTML and the things that only the server knows that changed. I guess I was thinking that the functionality you are looking for would be done with a custom toolbar (which is very easy to put together). But I do not want to dismiss your approach as the more information the client has the more kinds of things we can do in general! I could accept the patch for now and then put this as a limitation as the solution is apparent. Lets think about it for a couple days!
Status:
Accepted
Jul 14, 2009
Pardon me, but as far as I can see his works with ajax :)
The limit is updated in the HtmlSnippetsImpl.initJavascriptLimit() method, called
when the table is refreshed through ajax.
Patch for HtmlSnippetsImpl.java:
public String initJavascriptLimit() {
...
+ html.tab().append("jQuery.jmesa.setTotalRowsToLimit('" + limit.getId() +
"','" + limit.getRowSelect().getTotalRows() + "')").semicolon().newline();
...
}
I tested this with a big table, and after applying a filter that returned only one
row the limit was refreshed accordingly: totalRows was updated with the value 1.
But there have been occasions where I haven't seen much beyond the tip of my nose
and I wouldn't wonder this is one of them ;)
Jul 14, 2009
Hey, your right! I put an alert in the snippets file and it worked using AJAX. I had no idea. I think at one point I even tested this out, but that was before I was using jQuery. That or I am losing my mind :). Either way it works. Thats great news. I will check in your patch tonight then!
Jul 14, 2009
Added to the trunk and will go out in the next release. Probably by the end of the month. I don't mind keep doing these incremental changes and I like to release as soon as possible.
Jul 14, 2009
(No comment was entered for this change.)
Status:
Fixed
|