-
4 Feb 2010 8:33 AM #1
Set Icon to StoreFilterField MenuItem
Set Icon to StoreFilterField MenuItem
Hi all,
I have added a StoreFilterField item to a menu:
Menu.add(StoreFilterField)
Similar to the MenuItem where you can apply an icon using the setIcon method, I would like to be able to apply an icon to my StoreFilterField menu item option.
Any possible solutions would be much appreciated.
Thanks,
Susan.
-
4 Feb 2010 8:41 AM #2
Try to create a new class that extends StoreFilterField and implements IconSupport.
Not sure if that will work, thought.
You can give it a try.
Regards,
Michel.
-
4 Feb 2010 9:17 AM #3
Hi,
I have put the following class together:
public class Filter extends StoreFilterField<Employee> implements IconSupport {
@Override
protected boolean doSelect(final Store<Employee> store, final Employee parent, final Employee record,
final String property, final String filter) {
final Employee emp = record;
final double salary = emp.getSalary();
if (salary < Integer.parseInt(filter)) {
return true;
}
return false;
}
@Override
public AbstractImagePrototype getIcon() {
return this.getIcon();
}
@Override
public void setIcon(final AbstractImagePrototype icon) {
this.setIcon(icon);
}
@Override
public void setIconStyle(final String icon) {
// TODO Auto-generated method stub
}
}
But get the following error:
17:09:41.252 [ERROR] [gwt20project] Uncaught exception escaped
java.lang.StackOverflowError: null
at com.corm.client.networktab.Filter.setIcon(Filter.java:47)
-
4 Feb 2010 9:26 AM #4
you have the autogenerated methods not right implemented
and with "this.setIcon" you call the same method by yourself ... thats wrong.
best weay: you have to look how other classes in the sourcecode has implemented the IconSupport and make the same with your class.This forum needs your help: you got hints from the community and now you have fixed your code? dont just reply with "now its fixed" or "i found the error"! please take the time to post also an detailed answer with the working code.
GreaseMonkey Script for a GXT-only Forum: it hides ExtJs here: New Posts • Search Results • Advanced Search form • Category overview http://www.extjs.com/forum/showthrea...041#post410041
-
5 Feb 2010 5:03 AM #5
Exactly...
For example try to copy MenuItem implementations of it...
-
2 Jun 2010 10:41 PM #6
Hi,
I had implemented a class just like the above description,
and there is a icon next to my storefilterfield menu item.
However, it doesn't looks correct...
filtermenu.png
Does someone get any idea?
Here is the class code
Code:class ReportDataFilterField extends StoreFilterField<ReportData> implements IconSupport { private String style; protected AbstractImagePrototype icon; public ReportDataFilterField() { this.style = "x-menu-item"; } @Override protected boolean doSelect(Store<ReportData> store, ReportData parent, ReportData record, String property, String filter) { String data = record.get(String.valueOf(field)); if (data.contains(filter.toLowerCase())) { return true; } return false; } @Override public AbstractImagePrototype getIcon() { return icon; } @Override public void setIcon(AbstractImagePrototype icon) { if (rendered) { El oldIcon = el().selectNode(style); if (oldIcon != null) { oldIcon.remove(); } if (icon != null) { Element e = icon.createElement().cast(); El.fly(e).addStyleName(style); el().insertChild(e, 0); } } this.icon = icon; } @Override public void setIconStyle(String icon) { setIcon(IconHelper.create(icon)); } @Override protected void afterRender() { super.afterRender(); setIcon(icon); } }


Reply With Quote