Announcement

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

    ListGird Filtering when using getCellValue

    Version v12.1p_2020-08-27/Pro Deployment (2020-08-27)

    Hello,

    I'm using getCellValue to derive values for one of the fields in a ListGrid. I also have filtering enabled. I'm stuck trying to get the filtering to work... since the underlying DataSource doesn't have the values that are displayed in that column, the filtering has no impact.

    Is there something similar to "sortNormalizer" available - ie., some way to inform the filter of what to look at? Or some other recommendation for how to approach this situation?

    Thanks,

    Philip



    #2
    Hi philip.haven@milliman.com,

    please see ListGridField.setFilterEditorProperties() in combination with FormItem.setCriterionGetter().

    Best regards
    Blama

    Comment


      #3
      Sorry, this is the SmartClient, not the SmartGWT forum. The same properties exist in Javascript, see here.

      Comment


        #4
        Philip, overriding getCriterion() could be part of a successful strategy, but you need to consider server- and client-side filtering and having them match up.

        If you want to filter on a formatted value, you likely want to have the formatted version of the value produced at the lowest level you can (eg in SQL) so that criteria submitted from the client work against the formatted value in the SQL query, and the same criteria function identically on the client since they are also looking at the formatted value (in this case, there is no getCellValue on the client - the value it receives is the formatted value).

        Various other strategies exist, depending on whether client-side filtering is necessary (it can be turned off - look for useClientFiltering) and the specific underlying data value and filtering rules.

        Comment


          #5
          Thanks for the replies and information.

          Some additional info regarding my case:
          • I'm interfacing with a legacy API endpoint that I don't have control over
          • Filtering is only taking place client-side
          • The data in the column I want to filter on doesn't have a corresponding field in the API return... it's stitched together by looking at several fields on the record. ie., it's more than just formatting.
          Given that - would it make the most sense for me to create the values for this derived field in the DataSource.transformResponse instead of using ListGrid.getCellValue? I'm assuming that if I did that, then the filtering would just work?

          Thanks again.

          Philip

          Comment


            #6
            Yes, if you only need client-side filtering, then putting together the value in transformResponse() is a great way to do it, and filtering will just work.

            Comment


              #7
              Thanks - that worked!

              Comment

              Working...
              X