Announcement

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

    Pick List Issue

    Hi,

    I have created a selectItem with setMultiple as true on the listgrid filter. Whenever I select multiple values from the drop down, the data below gets filtered. Also, the comma separated values appear in the box above. But when we open the dropdown again, the first value in the dropdown appears selected. None of the actual values appar selected.

    Example: Suppose I have A,B,C,D,E,F,G,H in the multi-select drop-down list. If I select the D and E then GWT automatically deselects D and E and Selects the first item in list i.e.; A. However the box on the filter grid is showing D,E. But in the drop-down shows A as selected.


    ListGridField attr;
    SelectItem hdwattr = new SelectItem();
    DataSource hardwareAttrDS = DataSource.get(ATTRIBUTES_DS);
    hdwattr.setSortField(0);
    hdwattr.setDisplayField("printCode");
    hdwattr.setValueField("printCode");
    attr.setFilterOperator(OperatorId.IN_SET);
    hdwattr.setMultiple(true);
    hdwattr.setMultipleAppearance(MultipleAppearance.PICKLIST);
    hdwattr.setShowAllOptions(true);

    hdwattr.setPickListFilterCriteriaFunction(new FormItemCriteriaFunction() {

    @Override
    public Criteria getCriteria(FormItemFunctionContext itemContext) {
    Criteria criteria = new Criteria();
    criteria.addCriteria(IS_FROM_MAINTENANCE, true);
    return criteria;
    }
    });

    hdwattr.setAutoFetchData(false);
    hdwattr.setAllowEmptyValue(true);
    attr.setFilterEditorProperties(hdwattr);

    #2
    Your criteria function is broken: it just completely ignores the currently selected values and sends fixed criteria. This would render the control non-functional for filtering in general, but in addition, in the context of the filterEditor this would cause the values to be cleared out.

    Comment


      #3
      My criteria bring the correct data whenever the criteria changes, In fact, there are some more criteria added in the setPickListFilterCriteriaFunction.
      The only issue is that why GWT deselects all the selected value from my pick list? In fact, it filters my grid data correctly but the picklist shows always the first item as selected.

      Comment


        #4
        So again, your FormItemCriteriaFunction is totally wrong - ignores the selected values and just sends fixed criteria - and would create the problem you're having. If filtering sometimes works despite this function being totally wrong, perhaps you have some other hack partially compensating. You still need to fix your FormItemCriteriaFunction.

        Comment


          #5
          hdwattr.setPickListFilterCriteriaFunction(new FormItemCriteriaFunction() {

          @Override
          public Criteria getCriteria(FormItemFunctionContext itemContext) {
          Criteria criteria = new Criteria();
          criteria.addCriteria(IS_FROM_KEYNOTE_MAINTENANCE, true);
          criteria.addCriteria(TOGGLE_CALL_FOR_FILTER, TOGGLE_FOR_FILTER);
          criteria.addCriteria(v_ID, csvm);
          criteria.addCriteria(pb_id, KMV.cspb);
          if (currentSelectedProductLine != null) {
          criteria.addCriteria(PL,currentSelectedProductLine);
          }
          criteria.addCriteria(ATTR_NUMBER,attrNumber);
          if (currentSelectedHardwareType != null) {
          criteria.addCriteria(HTID,csht);
          }
          TOGGLE_FOR_FILTER = !TOGGLE_FOR_FILTER;
          return criteria;
          }
          });

          This is my full FormItemCriteriaFunction. Where csvm, cspb, csht , attrNumber are the value which changes every time and In fact a call goes to the controller with criteria having an updated value.
          I have attached a GIF file, The drop down gets populated with value in the grid fields, But whenever I select 72" and 20", The drop down deselects both and selects 16"(1st one always) While the box on the top of grid filter displays 72",20" and even filters the data correctly, In fact the call goes to backend with the attr2Value = 72 " , 20" and InSet operation
          Attached Files

          Comment


            #6
            This function is no longer obviously broken, however, you haven't provided information that would allow us to help further. We suspect you've added code of your own, that, for example, rejects changes by calling cancel() in a change handler, or calls setValue() on the control. Let us know if you can provide some way to reproduce this issue.

            Comment


              #7
              I have added
              ha.setValueField("pc");
              what should be the type of "pc" in the ds.xml??In order to display the multi select attr, pc should be the array of strings. what should be the type of value that controller should return??
              ha.setValueMap("A", "B" , "C");

              There is nothing anything extra written apart from these criteria and the method in first post.
              In the same Grid, we have even single select ComboBoxItem Which works very fine. Selects one value and filters.

              Can you provide me some source where "MultiSelect on the gird filter" has been implemented earlier

              Comment


                #8
                Data format and expected behavior for criteria of multiple:true fields is covered in the docs for dataSourceField.multiple. We're not sure what you mean about your "controller" (this is not a term used in the SmartGWT framework) but in server-side Java, the data to be returned should be a List or Array.

                We're also not sure what the setValueMap() call means, but that would not apply here.

                Comment


                  #9
                  Note that it's not clear here whether you actually want dataSourceField.multiple:true. That would be used if the DataSourceField actually holds an Array value (eg multiple printCodes in your terminology).

                  If you are simply trying to filter using inSet on a normal (non-multiple field), the server never ends up returning arrays of fields for the field, it just returns matching records as with any other criteria.

                  Finally, as far as a working sample, you can take a sample like this one and just apply filterEditorProperties to enable a multiple SelectItem, eg to the Continent field, and filtering works normally with no issue as you describe.

                  Comment


                    #10
                    It worked after having a separate ds.xml for this functionality.

                    Comment

                    Working...
                    X