Closed GoogleCodeExporter closed 9 years ago
You are going to have to do something similar to what the current filters are
doing.
Take a look at the JMesa JavaScript...it for sure is not trivial to get it to
look
nice across browsers and such. You should be able to do something similar to
what the
default filter is doing though.
Original comment by jeff.johnston.mn@gmail.com
on 2 Sep 2009 at 6:03
I've tried adding a function I called "createDateRangeFilter" to the
jquery.jmesa.js
filterapi var. I've also added the function to jmesa.jar, copying the
"createDynFilter" function. The function is identical to the "createDynFilter"
function. I've tried calling it using the FilterEditor:
HtmlBuilder html = new HtmlBuilder();
html.div().styleClass("dynFilter").onclick("jQuery.jmesa.createDateRangeFilter(t
his,
'bankTransactions', 'date')").divEnd();
return html.toString();
Nothing happens. When I replace "createDateRangeFilter" with "createDynFilter"
in
the div, it behaves just like all the other filters. Am I missing a step here?
Original comment by ryan.hen...@gmail.com
on 4 Sep 2009 at 8:18
Do you get any JavaScript errors? Do you use Firebug with Firefox to work with
JavaScript?
Original comment by jeff.johnston.mn@gmail.com
on 8 Sep 2009 at 10:52
Original comment by jeff.johnston.mn@gmail.com
on 20 Oct 2009 at 8:18
I have tried to implement and it works. Here is the link
http://blog.ketankhairnar.com/2009/11/adding-jquery-datepicker-to-jmesa-grid.htm
l
Original comment by ketan.kh...@gmail.com
on 26 Nov 2009 at 12:22
I'm very interesting in your article, but the URL has expired :(
Original comment by andyned...@gmail.com
on 22 Apr 2010 at 9:52
Ketan was kind enough to send me the code to use Datepicker with JMesa:
In JSP:
entry for the jmesa table as follows
<jmesa:tableFacade
id="worksheet"
editable="false"
items="${items}"
maxRows="25"
exportTypes=""
maxRowsIncrements="25,50,100"
stateAttr="restore"
toolbar="com.xx.portal.util.jmesa.CustomToolbar"
filterMatcherMap="com.xx.portal.util.jmesa.PDADateFilterMatcherMap"
var="pdaCycleInfo">
......
<jmesa:htmlColumn property="importDateTime" title="Import Date"
editable="false" width="150px"
pattern="yyyy-MM-dd" cellEditor="org.jmesa.view.editor.DateCellEditor"
filterEditor="com.xx.portal.util.jmesa.DateRangeFilterEditor"
/>
.............
public class PDADateFilterMatcherMap implements FilterMatcherMap
{
public Map<MatcherKey, FilterMatcher> getFilterMatchers()
{
Map<MatcherKey, FilterMatcher> filterMatcherMap = new HashMap<MatcherKey,
FilterMatcher>();
filterMatcherMap.put(new MatcherKey(Date.class, "importDateTime"), new
DateFilterMatcher("yyyy-MM-dd"));
return filterMatcherMap;
}
}
.............
public class DateRangeFilterEditor extends AbstractFilterEditor
{
@Override
public HtmlColumn getColumn()
{
return (HtmlColumn)super.getColumn();
}
public Object getValue()
{
HtmlBuilder html = new HtmlBuilder();
Limit limit = getCoreContext().getLimit();
HtmlColumn column = getColumn();
String property = column.getProperty();
Filter filter = limit.getFilterSet().getFilter(property);
String filterValue = "";
if (filter != null)
{
filterValue = filter.getValue();
}
html.div().styleClass("dynFilter");
html.onclick("jQuery.jmesa.createDynDateFilter(this, '" + limit.getId() +
"','" + column.getProperty() + "')");
html.close();
html.append(escapeHtml(filterValue));
html.divEnd();
return html.toString();
}
}
--------------
Add following to jquery.jmesa js in filter section
createDynDateFilter : function(filter, id, property) {
if (dynDateFilter) {
return;
}
dynDateFilter = new classes.DynFilter(filter, id, property);
var cell = $(filter);
var width = cell.width();
var originalValue = cell.text();
/* Enforce the width with a style. */
cell.width(width);
cell.parent().width(width);
cell.css('overflow', 'visible');
cell.html('<div id="dynFilterDateDiv"><input id="dynFilterDateInput"
name="filter" style="width:' + (width + 2) + 'px" value="" /></div>');
var input = $('#dynFilterDateInput');
$("#dynFilterDateInput").datepicker({
duration: '',
dateFormat: 'yy-mm-dd',
showTime: false,
constrainInput: false
});
input.val(originalValue);
input.focus();
$(input).keypress(function(event) {
if (event.keyCode == 13) { /* Press the enter key. */
var changedValue = input.val();
cell.text('');
cell.css('overflow', 'hidden');
cell.text(changedValue);
$.jmesa.addFilterToLimit(dynDateFilter.id, dynDateFilter.property,
changedValue);
$.jmesa.onInvokeAction(dynDateFilter.id, 'filter');
dynDateFilter = null;
}
});
$(input).change(function() {
var changedValue = input.val();
cell.text('');
cell.css('overflow', 'hidden');
cell.text(changedValue);
$.jmesa.addFilterToLimit(dynDateFilter.id, dynDateFilter.property, changedValue);
$.jmesa.onInvokeAction(dynDateFilter.id, 'filter');
dynDateFilter = null;
});
},
Original comment by andyned...@gmail.com
on 26 Apr 2010 at 6:44
Original issue reported on code.google.com by
ryan.hen...@gmail.com
on 31 Aug 2009 at 8:01