Announcement

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

    Support Methods for Search of Existence of Fieldname or Key in AdvancedCriteria, and get value

    This primarily a client side general question about AdvancedCriteria. We have come across the need to find if an AdvancedCriteria contains a particular field/key criterion and what is the value of the criterion. Take this simple case:

    Code:
      
    
     AdvancedCriteria c = new AdvancedCriteria(OperatorId.AND, new Criterion[] { 
                                                    new Criterion((isERC) ? "ERC_RuleCheckName":"DRC_RuleCheckName", OperatorId.IN_SET, item.getValues()),
                                                  new Criterion ( "canExpand", OperatorId.CONTAINS, "true"),
                                                new Criterion ( "Total_Num", OperatorId.GREATER_THAN, 0)
    
    });
    Some other method gets passed this criteria c, and it wants to find check if the field named "ERC_RuleCheckName" or "DRC_RuleCheckName" exists, and what is it's value.

    We have a support utility that recursively goes down an AdvancedCriteria and searches for the existences of Criterion that contains the passed field name. One version of the utility that returns a true or false, if the field exists, and another that returns the value or null. The utility is recursive as there may be many AdvancedCriteria in a wrapper Criteria.

    Is there a method that we have missed in the documentation that does this more efficiently, or can replace our recursive utility that we are missing?

    Finally is there an equivalent for the server side code?

    I don't believe it is important to qualify this question with a particular version of SmartGWT, but we are on a late July 2018 build of 6.1.



    #2
    We have a server-side API AdvancedCriteria.getFieldValue() that does the same thing as your latter method (find the criteria value by recursive search). See also dsRequest.getCriteriaValue(), often more convenient as it handles simple criteria as well.

    We have no similar client-side method, and there is no way to be more efficient than a recursive search (there is no internal index structure or anything like that), so you should continue using your own utility.
    Last edited by Isomorphic; 17 Aug 2018, 11:16.

    Comment


      #3
      Thanks.

      Comment

      Working...
      X