autocomplete && filterEditor?

45 views
Skip to first unread message

sheep

unread,
Feb 19, 2012, 10:53:40 AM2/19/12
to jmesa_forum
how to use JQuery Autocomplete plugin for filter Editor?such as,i have
a list of {ab,ac,bc} and i input "a" in filter editor,it can imply
"ab",“ac”
this document is about Autocomplete and WorksheetEditor.is there
example for filterEditor?
thank you!

sheep

unread,
Feb 20, 2012, 12:52:31 AM2/20/12
to jmesa_forum
i try like this,but it doesn't succeed
public class AutoFilterEditor 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.createAutoDynFilter(this, '" +
limit.getId() + "','" + column.getProperty() + "')");
html.close();
html.append(escapeHtml(filterValue));
html.divEnd();
return html.toString();
}
}


createAutoDynFilter : function(filter, id, property) {
if (autoDynFilter) {
return;
}
autoDynFilter = 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="dynFilterDiv"><input
id="dynFilterInput" name="dynFilterInput" style="width:' + (width + 3)
+ 'px" value="" /></div>');

var data = new Array("100000","110000","111000");
$("#dynFilterInput").autocomplete(data, {
minChars: 0,
max: 12,
autoFill: true,
scroll: true,
mustMatch: false,
matchContains: false,
scrollHeight: 220,
formatItem: function(data, i, total) {
return data[0];
}
});
var input = $('#dynFilterInput');
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(autoDynFilter.id,
autoDynFilter.property, changedValue);
$.jmesa.onInvokeAction(autoDynFilter.id,
'filter');
autoDynFilter = null;
}
});
$(input).change(function() {
var changedValue = input.val();
cell.text('');
cell.css('overflow', 'hidden');
cell.text(changedValue);
$.jmesa.addFilterToLimit(autoDynFilter.id,
autoDynFilter.property, changedValue);
$.jmesa.onInvokeAction(autoDynFilter.id, 'filter');
autoDynFilter = null;
});
},




<jmesa:htmlColumn property="number" title="number" editable="false"

filterEditor="com.base.AutoFilterEditor" width="50"/>


Jeff Johnston

unread,
Feb 20, 2012, 8:15:28 PM2/20/12
to jmesa...@googlegroups.com
You have the right idea. You defined a filter editor and put in some custom Javascript.

Because this is so custom the most I would be able to do is verify that your custom editor is being called. Beyond that this is very custom functionality so you would have to work through what it takes to get working like you need.

Feel free to keep asking questions though if something about the way that JMesa is calling your FilterEditor is not working.

-Jeff Johnston

AMRAOUI Marouane

unread,
May 3, 2013, 3:51:57 AM5/3/13
to jmesa...@googlegroups.com

Hello I'm asking if you get it work ? i need to do the same : have a autocomplete filter. 
so if you can share your experience with me i will be very gratefull.

thx in advance.
Reply all
Reply to author
Forward
0 new messages