Announcement

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

    SelectItem for ListGrid Column - Show Current Filtered Values Only

    I would like the values in a SelectItem to be all of the values currently present in the ListGrid.

    So if there are normally 20 values listed in the SelectItem, but then the user applies filters to other columns leaving only 5 distinct values for that SelectItem in the ListGrid column I need only those 5 values to appear in the dropdown list.

    Would you be able to show me an example of setting up a SelectItem to function this way?

    Thanks in advance for the help,
    Patrick

    #2
    Assuming the main grid is using load on demand (hence not all values may be loaded) the correct way is to override getPickListFilterCriteria() and return criteria that match what is currently applied to the ListGrid.

    Comment


      #3
      Thanks for this info. It looks like exactly what we are looking for.

      Here is what I tried...
      I have a SelectItem in the FilterEditor for a column in myListGrid.

      I set the options Datasource to be the same datasource as that of myListGrid.
      I override the method you mentioned in the SelectItem to return myListGrid.getCriteria().

      It seems to just spin in "fetching data" on the initial load and never completes.

      Did I misunderstand this approach or miss a step?

      Thanks again for the help.
      Patrick

      Comment


        #4
        Hi Patrick

        Code:
        final Criteria pickListCriteria = new Criteria();
        pickListCriteria.setAttribute("accountType", "Driver");
        		
        driverList = new GetSelectItem(FN_LOADS_DRIVER, TN_LOADS_DRIVER, 180, 30);
        driverList.setValueField("userId");
        driverList.setDisplayField("name");
        driverList.setOptionDataSource(DataSource.get(USER_DMI));
        driverList.setPickListCriteria(pickListCriteria);
        Here I have two selectItem Truck and Driver based on the Truck Selected the Driver SelectItem will be populated. For this I have used driverList.setValue() on TruckList changedHandler event is fired

        I hope this helps you

        Comment


          #5
          We can't tell what went wrong from just that - we would need the usual diagnostics in order to help.

          Comment


            #6
            Shaddha: Thanks for the info. We will take a look at that.

            Isomorphic:

            Here is the code block we are using to try and only show the values in the dropdown that are currently in the ListGrid. Please let us know if you see any issues. Thanks!

            Code:
                  ListGridField gridField = theListGrid.getField(field_with_select_item_header);
                  gridField.setOptionDataSource(DataSource.get(same_datasource_as_listgrid);
            
                  // Create the select item that will be used in the ListGrid Column FilterEditor
                  SelectItem selectItem = new SelectItem()      
                  {
                	  @Override
                	  public Criteria getPickListFilterCriteria() {
                		  return theListGrid.getCriteria();
                	  }
                  };
            
                  selectItem.setMultiple(true);
                  selectItem.setAllowEmptyValue(true);
                  gridField.setFilterEditorProperties(selectItem);

            Comment


              #7
              That's not really what we meant by the "usual diagnostics" - we mean basic troubleshooting info like whether there's a JS error, whether a request is sent to the server and what's in it, what the server responds with, etc.

              Comment


                #8
                I will work on getting more of the information you requested.

                I have an update.

                I created a SelectItem using the method you described where it uses an overriden getPickListFilterCriteria() to return the ListGrid's current criteria.

                When I add it to a column in the header of the ListGrid it does not filter the values of the SelectItem based on the settings of the other filters. I do not get any errors.

                However, when I just move the exact same SelectItem to the page itself (separate from the ListGrid FilterEditor) it filters down the values based on the ListGrid filters as expected.

                I have verified this behavior by modifying one of the sample applications and saw the same thing.

                I just wanted to pass along in case this helps narrow down the issue.

                Thanks,
                Patrick

                Comment


                  #9
                  If you mean you're adding it to the FilterEditor via setFilterEditorType(), see the docs for getPickListFilterCriteria for the approach to use to be compatible with setEditorType() / setFilterEditorType().

                  Comment


                    #10
                    You got us going in the right direction. Thanks for the reply.

                    We set setPickListFilterCriteriaFunction() on the selectItem to return the current ListGrid criteria. This gave us what we were looking for for the SelectItem in the FilterEditor.

                    However, we realized this would not work once we set a filter (which narrowed down the list) and then pulled the dropdown again and realized we no longer got the full list. It was doing exactly what we asked for, but we didn't realized this ahead of time.

                    Now we are setting the method ahead of time to be some subset of the current criteria of the ListGird and we expect this will be just what we are looking for.

                    Thanks again for the help.

                    Comment

                    Working...
                    X