Announcement

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

  • Criteria stringifier / localization of operators from Criteria

    Hello Isomoprhic or anyone,

    in our application, we use a FilterBuilder to filter a ListGrid using the FilterBuilder.getCriteria() and ListGrid.FilterData(Criteria) methods. This all works fine.
    What we want though, is a way of representing the actual criteria in a user-friendly readable string.
    E.g.: criteria like these:
    Code:
    {
      _constructor:"AdvancedCriteria",
      operator:"and",
      criteria:[
          { fieldName:"salary", operator:"lessThan", value:"80000" },
          { operator:"or", criteria:[
              { fieldName:"title", operator:"iContains", value:"Manager" },
              { fieldName:"reports", operator:"notNull" }
            ]  
          }
      ]
    }
    convert as such:
    [Salary < 8000] and [[title contains(ignore case) Manager] or [reports notNull]]

    So I'd have two questions:

    1. Is there any method to achieve such conversion of Criteria into a nice looking string? I haven't found any.

    2. If not, then it's no biggie for me as I do already have code to achieve this in some way.
    The problem I'm having is with localization of operators from Criteria. The operators are being correctly localized inside the respective FormItems in the FilterBuilder but how do I localize an operator obtained from Criteria.getOperator() (which returns OperatorId String value)?

    Thanks a lot

    (SmartClient Version: v11.1p_2017-10-13/Pro Deployment (built 2017-10-13))
    Attached Files

  • #2
    Please see this other post

    Comment


    • #3
      In fact, in 6.1 you can use getAdvancedCriteriaDescription().

      Comment


      • #4
        Hi, thanks for the answers.
        However, here is the same issue with the getAdvancedCriteriaDescription() method as in the post you mentioned earlier.
        The localization of operators is not fully supported (equal/not equal do not get localized and maybe a couple more that I have not checked).

        (PS: tested for german localization)
        Last edited by admin@seacomp.cz; 12th Jan 2018, 05:09.

        Comment


        • #5
          We've made some enhancements to have getAdvancedCriteriaDescription() produce localised output, by including the localised descriptions of the operators - there may be some loss of grammatical precision, since we're only building very simple sentences, and we have a single process for all locales.

          You can test the changes in builds of 6.1+ dated January 14 and later.

          Comment


          • #6
            Thanks for the quickfix!
            I did not have the time to upgrade and test it yet, but will do so soon.

            There is one more thing that I have noticed using the FilterBuilder.
            When i choose any operation that compares two fields (less than field, greater than field, ...) the outcome of the getAdvancedCriteriaDescription() is not exactly right.
            The problem is, that the method probably uses field's name rather than it's title. An example is in the attached screenshot. Click image for larger version

Name:	filterBuilder_fieldNames.png
Views:	1
Size:	12.7 KB
ID:	251225
            The filterBuilder editors show the field title, the bottom string is an unchanged output of getAdvancedCriteriaDescription() method.

            Comment


            • #7
              We've fixed that one too - you can test it out in builds dated January 17 and later.

              Comment

              Working...
              X