Announcement

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

    ComboboxItem client side filtering with OptionCriteria is not working

    Hi,
    I am using GWT 2.8.2 and SmartGWT 6.1-p20170724 power version.

    I am using comboboxitem as a editor in ListgridField.

    Code:
    ComboBoxItem item = new ComboBoxItem();
    item.setDisplayField(dto.getDisplayField());
    item.setValueField(dto.getValueField());
    if(dto.isPickList())
    {    
    item.setPickListFilterCriteriaFunction(itemContext -> buildPickCriteria(dto));
    } else {    
    item.setOptionCriteria(buildCriteria(dto));
    }
    item.setAutoFetchData(true);
    item.setAddUnknownValues(false);
    item.setAllowEmptyValue(true);
    item.setUseClientFiltering(true);
    
    //item.setFilterLocally(true);
    Now problem is that when I set setFilterLocally(true) then filtering on client side works but my optionCriteria is not sent to server for fetching record. Even first time request doesn't contain any criteria. And when i don't set setFilterLocally(true) then typing on comboBoxitem doesn't filter options till exact same value entered.

    In my case options values coming in capital letter and user tried to filter that value by typing on keyboard(which generally in lowercase). Then filtering doesn't work at all.

    Please suggest me how to enable search/filter on combobox with criteria?

    -- Kind Regards
    Last edited by sidharth1917; 24 Aug 2018, 04:14.

    #2
    This is exactly what the filterLocally property says it will do: fetch everything.

    If you want instead that your criteria is applied but all subsequent filtering is done locally, you could set dataFetchMode to "basic" on your pickListProperties.

    Note also that it sounds like your optionCriteria are being used to cause the server to *transform* data instead of filter it. This is invalid: criteria must be criteria, not data transform instructions, or many things will be broken. The correct way to have several variants of data come from the same DataSource is to use different operationBinding.operationIds.

    Comment


      #3
      Hi,
      Thanks for reply.

      I am still facing issue on filtering.
      I have removed setFilterLocally, And created separate operationId. However there are some listGridField which is dependent on selected value of another listGridField.
      So i am sending criteria as following for that
      Code:
      //dependentListGridFieldName is the name of the field by which data of this field fetched from database
      
      comboBoxItem.setPickListFilterCriteriaFunction(itemContext -> {
         Criteria criteria = new Criteria();
         String val = listGrid.getSelectedRecord().getAttributeAsString(dependentListGridFieldName);
         criteria.addCriteria(dependentListGridFieldName, val);
         return criteria;
      });
      Now if i add this criteria Function to the comboBoxItem then my filtering on typing stops working.
      Please suggest how to achieve this.

      Comment


        #4
        Hi sidharth1917,

        see this code I'm using and watch out for itemContext.getFormItem().getValue():

        Code:
                setPickListFilterCriteriaFunction(new FormItemCriteriaFunction() {
                    @Override
                    public Criteria getCriteria(FormItemFunctionContext itemContext) {
                        Criterion currentCountryCriteria = new Criterion(DatasourceFieldEnum.MV_ZIPCODE__COUNTRY_ID.getValue(), OperatorId.EQUALS,
                                selectedCountry.getValueAsString());
                        if (itemContext.getFormItem().getValue() != null) {
                            Criterion currentZipcodeCriteria = new Criterion(DatasourceFieldEnum.MV_ZIPCODE__ZIPCODE.getValue(), OperatorId.ISTARTS_WITH,
                                    itemContext.getFormItem().getValue().toString());
                            Criterion currentCityCriteria = new Criterion(DatasourceFieldEnum.MV_ZIPCODE__ORTSVORSCHLAG.getValue(), OperatorId.ISTARTS_WITH,
                                    itemContext.getFormItem().getValue().toString());
                            Criterion currentCityCriteria2 = new Criterion(DatasourceFieldEnum.MV_ZIPCODE__ORTSVORSCHLAG.getValue(), OperatorId.ICONTAINS,
                                    " " + itemContext.getFormItem().getValue().toString());
                            AdvancedCriteria zipcodeOrCity = new AdvancedCriteria();
                            zipcodeOrCity.buildCriterionFromList(OperatorId.OR,
                                    new Criterion[] { currentZipcodeCriteria, currentCityCriteria, currentCityCriteria2 });
                            AdvancedCriteria countryAndZipcodeOrCity = new AdvancedCriteria();
                            countryAndZipcodeOrCity.buildCriterionFromList(OperatorId.AND, new Criterion[] { currentCountryCriteria, zipcodeOrCity });
                            return countryAndZipcodeOrCity;
                        } else
                            return currentCountryCriteria;
                    }
                });
        Best regards
        Blama

        Comment

        Working...
        X