Announcement

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

    Auto populate in Combo box

    Hi ,

    I have a requirement in which based on some parameters value change , the dropdown data should change, for that we used "setPickListFilterCriteriaFunction" for the sleect Item like this

    ComboBoxItem filterSelectItem = new ComboBoxItem();
    DataSource hdwAttrTypeDS = DataSource.get(ClientConstants.HARDWARE_ATTR_TYPE_DS);
    filterSelectItem.setSortField(DESCRIPTION);
    filterSelectItem.setDisplayField(DESCRIPTION);
    filterSelectItem.setValueField(DESCRIPTION);

    filterSelectItem.setOptionDataSource(hdwAttrTypeDS);
    filterSelectItem.setPickListFilterCriteriaFunction(new FormItemCriteriaFunction() {

    @Override
    public Criteria getCriteria(FormItemFunctionContext itemContext) {
    Criteria criteria1 = new Criteria();
    criteria1.addCriteria(PRICE_BOOK_ID, HardwarePriceBookViewPage.currentSelectedPriceBook);
    return criteria1;
    }
    });

    filterSelectItem.setAutoFetchData(false);
    attrTypeField.setFilterEditorProperties(filterSelectItem);
    attrTypeField.setFilterOperator(OperatorId.EQUALS);

    Now when i do like this , my purpose of dynamically populating the dropdown is served but the feature of auto populating the options when some character is typed is not working
    Like if i have values A,AB,ABC,ABCD in my dropdown so when i press A in the filter dropdown , it is not showing me the values starting or containing A


    When i remove the "setPickListFilterCriteriaFunction" and pass the crtieria normally , then it works

    #2
    Hi,

    you'll need to use something like
    Code:
    if (itemContext.getFormItem().getValue() != null) {
    .....
    }
    in your code and generate Criteria based on you static criteria as well as the entered text itemContext.getFormItem().getValue().

    Best regards
    Blama

    Comment


      #3
      Hi Isomorphic,

      I am facing exactly same issue with comboBoxItem where i am sending criteria using setPickListFilterCriteriaFunction that cause filter on typing to stop.
      I have raised a ticket regarding this issue here

      https://forums.smartclient.com/forum...is-not-working

      Please help me. I need some help on this urgently.

      Blama

      itemContext.getFormItem().getValue() is not helping much as I don't need criteria on current editing value instead I need to send criteria for initial fetch, And that criteria is not constant but changed on the basis of user selection on previous dropdown. And I dont need any call on server side when user typing on this comboBoxItem. Only criteria need to be send on first time data transform from server when user comes to this comboBoxItem or User went to previous or next cell then come back to this comboBoxItem.
      If you have any alternative approach please suggest.
      Thanks

      --
      Kind Regards
      Last edited by sidharth1917; 3 Sep 2018, 04:52.

      Comment


        #4
        Hi sidharth1917,

        please see this sample, which is exactly your use case.

        Best regards
        Blama

        Comment


          #5
          Hi Blama,

          We have implemented exactly same as given in this example. Only things changed is ComboBoxItem in place of SelectItem. Difference is that ccomboBoxItem provide textItem for typing and search from dropdown. So functionality till select item is working fine. I can fetch data with criteria and can select any of given value from dropdown. I can even search (filter) data in comboBoxItem when I dont provide dynamic criteria in comboBox.
          However in ComboBoxItem with dynamic criteria, when I start typing in textbox dropdown should get filtered like I have typed 'a' then 'a', 'ab', 'abc', 'abd', 'acd' values need to be shown only. But it is not happening instead all values are shown.

          I have reproduced this behaviour using sample code just changing SelectItem to ComboBoxItem. You can try using same. Thanks.
          --
          Kind Regards

          Comment


            #6
            Hi sidharth1917,

            if you used this then please look up the docs for the method:
            Code:
            However it is recommended that developers use [URL="https://www.smartclient.com/smartgwtee-6.1/javadoc/com/smartgwt/client/widgets/form/fields/ComboBoxItem.html#setPickListFilterCriteriaFunction-com.smartgwt.client.widgets.form.fields.FormItemCriteriaFunction-"]setPickListFilterCriteriaFunction(FormItemCriteriaFunction)[/URL] to build custom criteria instead of overriding this method directly.
            It is pretty obvious that this overrides default behavior. So it is back to my #2. Build criteria from the static criteria from the 1st item and the currently entered text yourself.

            Best regards
            Blama

            Comment


              #7
              Isomorphic:

              Perhaps the samples should use setPickListFilterCriteriaFunction() instead of an getPickListFilterCriteria()-override in both SmartGWT and SmartClient.

              Best regards
              Blama

              Comment


                #8
                There is no such APIs in SmartClient, it was added for SmartGWT so a method override is not necessary here (which is clunkier and less flexible in Java).

                Thanks for correctly answering this user's question.

                Comment


                  #9
                  Hi Isomorphic,

                  the SmartGWT sample linked in #4 uses the java-@override, while the docs suggest to use the setter. Then the problem is only in the SmartGWT sample.

                  Best regards
                  Blama

                  Comment


                    #10
                    Sure, we'll make that more consistent.

                    Just to clarify, either approach works.

                    Also, the two posters in this thread are from the same company, seemingly trying to pretend there's a framework issue here by cross-posting on each other's thread. There is no indication of a framework issue here however.

                    Comment


                      #11
                      Hi Isomorphic,

                      I can see the SGWT sample is changed in v12.0p_2018-09-08.

                      Best regards
                      Blama

                      Comment

                      Working...
                      X