Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Custom button for ListGrid filter

    Is there some possibility to add additional button to ListGrid filter? I need button that clears all filter values

    #2
    Hi god_gav,
    We are currently trying the same. We are not yet finished to test if it really works but it seems to work by setting filterEditorProperties on the ListGridField and then set the icons field. Here is a definition of a list grid field as an example:
    Code:
    {title: 'name', name: 'name', 
            filterEditorProperties : {required: false,
            icons : [ {
                src :"[SKINIMG]../../images/MyGreatClearImage.png",
                click: function (form, item, icon) {
                item.setValue(null);            
                }
             }],
        }
    this displays an icon next to the filter editor. I only checked for a text field and am not sure what happens with date or combobox fields.

    One other thing I am not yet sure how to do is to set the form item value in such a way so that the grid automatically gets refreshed. If I find that out then I will let you know. It would be great if you can do likewise ofcourse.

    gr. Martin

    Comment


      #3
      btw, I now see that you are using GWT and I am using Smartclient javascript directly. But I hope/am pretty sure that the Smartgwt api offers the same possibilities.

      gr. Martin

      Comment


        #4
        Thank you for response, but I meant something else: I want to add button not for the particular filterEditor, but to the whole filtering pane. Filtering pane usually contains only one filter button.

        Comment


          #5
          This is how we do it:

          Code:
          listGrid.addChild(new ClearListGridFilterButton(listGrid));
          
          public class ClearListGridFilterButton extends Button {
            private ListGrid listGrid;
          
            public ClearListGridFilterButton(final ListGrid listGrid) {
              this.listGrid = listGrid;
              configureSelf();
              setClickHandler();
            }
          
            private void configureSelf() {
              setIcon(IconName.CLEAR_LIST_GRID_FILTER);
              setPrompt(Texts.get.clearListGridFilterPrompt());
              setWidth(16);
              setHeight(22);
              setSnapTo("TR");
              setBorder("0");
              setPadding(0);
            }
          
            private void setClickHandler() {
              addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                  listGrid.setCriteria(null);
                }
              });
            }
          }

          Comment

          Working...
          X