1

GXT3 Whole Grid Filtering

This the code to perform the whole grid filtering

pagingGridControl.getStore().addFilter(new StoreFilter() {
  @Override
  public boolean select(Store store, Object parent, Object item) {
    if(txtKeyword.getValue()==null){
      return true;
    }else{
      if(txtKeyword.getValue().trim().equals("")){
        return true;
      }
      
      Cheap_Sale_AllowedBean obj=(Cheap_Sale_AllowedBean) item;
      String sKeyword=txtKeyword.getValue();
      AutoBean<Cheap_Sale_AllowedBean> bean = AutoBeanUtils.getAutoBean(obj);
      Map<String,Object> map= AutoBeanUtils.getAllProperties(bean);
      for (String s : map.keySet()) {
        //Console.writeLine(s + "=" + map.get(s));
        if(map.get(s) !=null){
          if(map.get(s).toString().toLowerCase().indexOf(sKeyword) > -1){
            Console.writeLine(s + "=" + map.get(s));    
            return true;
          }
        }
      }          
    }
    return false;
  }
});

pagingGridControl.getStore().setEnableFilters(true);

The store filters must be enabled.

Source : http://www.sencha.com/forum/showthread.php?270023-Grid-Search

0

Textfield blur event not triggered when click on button's icon.

I read the GXT forum and just realize that Textfield blur event is not triggered when a button with icon is clicked on the icon. I found a temporary solution to handle this situation. Before submit the data, the textField finishEditing() function must be called.

Here is the code from my project. I'm going to put it in my library after this.


int widgetCount=toolbar.getWidgetCount();
for(int i=0; i < widgetCount;i ++){
  Widget w=toolbar.getWidget(i);
  if(w.getClass().equals(TextField.class)){
    TextField t=(TextField) w;
    t.finishEditing();                       
  }
}

Source : http://www.sencha.com/forum/showthread.php?258421-Field-and-blur-event
0

GXT3 Input Maxlength

I just migrated from GXT2 to GXT3.
Most of my previous code does not work and I got a problem to fix MAXLENGTH input element.
Luckily, the solution is very simple. Here is the code

textbox.getCell().getInputElement(textbox.getElement()).setMaxLength(maxLength);

This code worked for TextField, TextArea, NumberField<Integer> and NumberField<Double>.

But for NumberField, this syntax must be applied after the value has been set. If not, the maxlength attaribute will be removed.

Source : http://www.sencha.com/forum/showthread.php?178262-Setting-max-length-on-TextField
 
Copyright © peyotest