1. #1
    Ext User
    Join Date
    Jan 2010
    Posts
    7
    Vote Rating
    0
    slynch is on a distinguished road

      0  

    Default 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.

  2. #2
    Sencha User
    Join Date
    Nov 2008
    Location
    Vienna - Austria
    Posts
    868
    Vote Rating
    1
    micgala is on a distinguished road

      0  

    Default


    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.

  3. #3
    Ext User
    Join Date
    Jan 2010
    Posts
    7
    Vote Rating
    0
    slynch is on a distinguished road

      0  

    Default


    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. #4
    Ext User
    Join Date
    Sep 2008
    Location
    Germany
    Posts
    961
    Vote Rating
    1
    Arno.Nyhm is on a distinguished road

      0  

    Default


    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. #5
    Sencha User
    Join Date
    Nov 2008
    Location
    Vienna - Austria
    Posts
    868
    Vote Rating
    1
    micgala is on a distinguished road

      0  

    Default


    Exactly...

    For example try to copy MenuItem implementations of it...

  6. #6
    Sencha Premium Member
    Join Date
    May 2010
    Posts
    17
    Vote Rating
    0
    KeanuLee is on a distinguished road

      0  

    Default


    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); 
            } 
        }