Announcement

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

    Specifying criteria sent to server for listgridfield

    Currently running smartgwtee 3.0 on RHEL 5.X and Firefox 10. I have a listgrid and several fields on the listgrid. One of the fields is called "Value" and is of type float. I want to create a value map for it that has the blank option to show all values, which it does by default, and a "Outlier Only" value. For the outlier only value I would like to display that string and if it is chosen I would like to add the following to the where clause:
    Code:
    where value > maximum or value < minimum
    So if nothing is chose, all values are displayed and if the "Outlier Only" select item is selected then I want to get the outliers. How can I go about doing this?

    #2
    Basically just add your two special values to the valueMap along with the normal values. When you receive a DSRequest from this interface on the server, look at the criteria submitted for this field and modify it (probably using the AdvancedCriteria helper classes) to generate the SQL you're looking for, which would be just an OrCriterion containing a GreaterThanCriterion and LessThanCriterion.

    Comment


      #3
      I've added a value map to the select item for the field but the value disappears after any filter is performed. The select item value appears on first load but then disappears.
      Code:
       ListGridField gridField = theListGrid.getField(fieldName);
      
            // Create the select item that will be used by the list grid field.
            SelectItem selectItem = new SelectItem();
            selectItem.setAllowEmptyValue(true);
            LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>();
            valueMap.put("OUTLIERS", "Outliers Only");
            selectItem.setValueMap(valueMap);
            gridField.setFilterEditorProperties(selectItem);
      The field is of float type, but the map is a string. My end goal is to show only outlier values if that select item is chosen, where outlier values are values that are > maximum or < minimum. How can I get this select item to not disappear after filtering?

      Comment


        #4
        Have you also set an optionDataSource on this field? You can't use a valueMap to add values to an optionDataSource if that's what you hoped would happen - you would need to fetch all the values from the optionDataSource in advance, then form a valueMap from those plus the special Outlier value.

        Comment


          #5
          I think it is easier if I change my approach. I can have the same datasource for the listgrid have 2 different fetch operations, a fetch and a fetchOutliers. I would then present the operator with a comboboxitem that will let him specify if he wants to see all values or just the outliers. When he chooses one i can call setFetchOperation(FETCHOP). Then I guess I would have to filter the table.

          Comment

          Working...
          X