Announcement

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

    getting "complete" criteria of a grid

    Hello, I'm looking for a best practice to get the same criteria the would be sent to the server if a grid issues a fetch, ie comprising the implicitCriteria and the filterEditor criteria.

    The use case is to send that criteria to the server for a custom DMI method.

    I think that I may safely use combineCriteria to combine the various criteria parts, correct?

    The other problem is how to treat the filterEditorCriteria and getCriteria() parts, considering that the filterEditor criteria may not have been submitted ? Is there available some helper method?

    #2
    Hi claudiobosticco,

    I assume you could work with the underlying data object and use it as a ResultSet and then call ResultSet.getCriteria().

    I did not find a direct getter for ResultSet method in SmartClient ListGrid, but for reference, this is what SmartGWT's ListGrid.getResultSet() looks like:
    Code:
    public ResultSet getResultSet() {
            JavaScriptObject dataJS = getAttributeAsJavaScriptObject("data");
            if(dataJS == null) return null;
            if(!ResultSet.isResultSet(dataJS)) {
                SC.logWarn("getResultSet(): data is not a ResultSet; returning null " +
                    "(if grouped, use getOriginalResultSet(); if unbound, use getRecordList(); " +
                    "can only be called on DataBoundComponents after initial data has been fetched)");
                return null;
            }
            return ResultSet.getOrCreateRef(dataJS);
        }
    Best regards
    Blama

    Comment


      #3
      Hello Blama , I didn't think of looking at the ResultSet, but ResultSet.getCriteria() doesn't include implicitCriteria. I see some undocumented methods on the ResultSet, though, such as getCombinedCriteria. Waiting for Isomorphic reply on that.

      Comment


        #4
        ResultSet.getCombinedCriteria() does return what you're looking for - all criteria applied to the current filter, including implicitCriteria and the various sources of explicit-criteria a grid can have; the filterEditor, advanced filterWindow and searchForm.

        We'll make getCombinedCriteria() public and likely expose a getter for implicitCriteria on DBC and ResultSet.

        In the meantime, it's safe to use combineCriteria() to combine grid.implicitCriteria with a call to grid.getCriteria(), which also retrieves the criteria from the ResultSet - so, grid.getCriteria() also includes the various potential sources of explicit-criteria.

        Comment


          #5
          Hi Isomorphic,

          SmartClient does not have getResultSet(), but of course one could use the JS code from SmartGWT. But it seems that ResultSet.isResultSet() is not doc'd, either. Is this on purpose?

          Best regards
          Blama

          Comment


            #6
            Originally posted by Isomorphic View Post
            We'll make getCombinedCriteria() public and likely expose a getter for implicitCriteria on DBC and ResultSet.

            SmartClient Version: v13.0p_2023-09-01/AllModules Development Only (built 2023-09-01)

            now I see those methods are documented, thank you very much

            Comment

            Working...
            X