Announcement

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

    ComboBoxItem with multiple filtering function.

    I bind my ComboBox with a Option-DataSource, that have a more then one property.
    How can i make multiple search/filtering in my ComboBoxItem?
    thx.

    #2
    can somebody help me?

    Comment


      #3
      Well odd to do it with a combobox and not selectitem, but how are you filtering now? With selectitem would simply pass your criteria to setPickListCriteria() and have as many fields as you wanted.

      Comment


        #4
        Thanks for the answer, but I do not understand how this criteria works.

        What I want is the following:

        I have a ComboBox with multiple columns (ListGridField on setPickListFields) when I type a text then looks/ filter my ComboBox, this text only in one column, but I want that my ComboBox search/filter typed text in several column.

        Who can i do this?
        Can you give me an Example?

        thx.

        Comment


          #5
          So you need to override getPickListFilterCriteria() which will have a Criteria with the text typed against the first field only. To search on the other fields, simply modify the criteria to search on the other fields with the text types in the combobox already. Here is how the code would look.
          Code:
          ComboBoxItem item = new ComboBoxItem("myBox") {
            @Override
            protected Criteria getPickListFilterCriteria() {
              Criteria c = return super.getPickListFilterCriteria();
              c.addAttribute("field2", item.getValue().toString());
              c.addAttribute("field3", item.getValue().toString());
              return c;
            }
          };

          Comment


            #6
            thx, but it's not work.
            Who can i filter on the fly?

            this is my code.

            Code:
            final DynamicForm form = new DynamicForm();
            	form.setWidth(300);
            
            	ListGridField code = new ListGridField(PlStaatDTO.CODE);
            	ListGridField staat = new ListGridField(PlStaatDTO.STAAT);
            
            	PlStaatDS<PlStaatDTO> plStaatDS = new PlStaatDS<PlStaatDTO>(new PlStaatDTO());
            
            	final ComboBoxItem multipleSearchComboBox = new ComboBoxItem(PlStaatDTO.CODE) {
            	    @Override
            	    protected Criteria getPickListFilterCriteria() {
            		Criteria c = super.getPickListFilterCriteria();
            		if (getValue() != null) {
            		    c.setAttribute(PlStaatDTO.CODE, getValue().toString());
            		    c.setAttribute(PlStaatDTO.STAAT, getValue().toString());
            		}
            		return c;
            
            	    }
            	};
            	multipleSearchComboBox.setValueField(PlStaatDTO.CODE);
            	multipleSearchComboBox.setWidth(240);
            	multipleSearchComboBox.setPickListWidth(450);
            	multipleSearchComboBox.setOptionDataSource(plStaatDS);
            
            	multipleSearchComboBox.setPickListFields(code, staat);
            
            	multipleSearchComboBox.setAutoFetchData(false);
            	form.setItems(multipleSearchComboBox);
            
            	form.draw();
            PlStaatDS
            Code:
            public class PlStaatDS<T extends BaseDTO<T>> extends BaseDataSource2<T> {
            
                public PlStaatDS(T objektDTO) {
            	super(objektDTO);	
            	init();
                }
            
            
                private void init() {
            	
            	DataSourceTextField code = new DataSourceTextField(PlStaatDTO.CODE);
            	code.setPrimaryKey(true);
            	DataSourceTextField staat = new DataSourceTextField(PlStaatDTO.STAAT);
            	
            	setFields(code,staat);
                }
            
            }

            Comment


              #7
              Should be addCriteria(), attributes don't affect the filter. Also the autocomplete functionality is on STARTS_WITH basis so if you add additional criteria it won't automatically act like an OR condition you'll need to set that up with an AdvancedCriteria.

              Comment


                #8
                Can you give me a little Example or where can i read about AdvancedCriteria?
                thx.

                Comment


                  #9
                  can somebody help me?

                  Comment


                    #10
                    I'm tryed the folowing:

                    Code:
                    final ComboBoxItem multipleSearchComboBox = new ComboBoxItem(PlStaatDTO.CODE) {
                    	    @Override
                    	    protected Criteria getPickListFilterCriteria() {		
                    		
                    		AdvancedCriteria advancedCriteria1 = new AdvancedCriteria(PlStaatDTO.CODE,OperatorId.OR);
                    		AdvancedCriteria advancedCriteria2 = new AdvancedCriteria(PlStaatDTO.STAAT,OperatorId.OR);
                    		
                    		
                    		Criteria c = super.getPickListFilterCriteria();
                    		if (getValue() != null) {
                    		    c.addCriteria(advancedCriteria1);
                    		    c.addCriteria(advancedCriteria2);		    
                    		}
                    		
                    		return c;
                    
                    	    }
                    	};
                    	multipleSearchComboBox.setValueField(PlStaatDTO.CODE);
                    	multipleSearchComboBox.setWidth(240);
                    	multipleSearchComboBox.setPickListWidth(450);
                    	multipleSearchComboBox.setOptionDataSource(plStaatDS);
                    
                    	multipleSearchComboBox.setPickListFields(code, staat);
                    
                    	multipleSearchComboBox.setAutoFetchData(false);
                    but it does't work.

                    what am I doing wrong?

                    Comment

                    Working...
                    X