Announcement

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

    Losing criteria on searching

    I want to do this:

    - Have a list grid
    - Set some criteria from code
    - Allow the user to search inside the results.

    The user should not be able to override the criteria set in code, only narrow the results.

    Fortunately, the fields I set the criteria for in code are hidden, and not available for the user to search, so no field has more than one filter.

    I have done this:
    - I have set the criteria with ListGrid.fetchData(criteria)
    - I have set the auto text match style to exact
    - I have set the text match style for the individual, searchable, displayed fields to iContains.

    The problem is, when the user enters something to the filter box, the original criteria I have set no longer seems to have any effect!

    I have attached the DSRequest which is sent before the user searching (just my criteria, set from code), and the second one, which is sent after the user entered the search string.

    By looking at this second query, I would say that it has my criteria, but the response it gets clearly does not fit. (Also attached, but had to truncate for size reasons. First record in preserved.)

    I have also attached the server-side log about parsing this second query.

    What could be wrong here?
    Attached Files
    Last edited by csillag; 18 Mar 2010, 21:35.

    #2
    Is there something else that I should post about this problem?
    If there is, please tell me, because I really need to have this sorted out in two days.

    Comment


      #3
      If you are trying to enforce fixed criteria, that should be done server-side, for example, use a DMI that modifies the DSRequest. See the "User-Specific Data" example.

      Comment


        #4
        On the long term, I wholeheartedly agree.

        On the short term, is there a way to do this on client side?
        (ie. let the user filter inside the shown records, but not outside the original criteria.)

        Fortunately, there is no overlap in the fields: the filters set by the code use hidden fields, so the user can not filter for them.

        What I do not understand is why my criteria seems to show up correctly in the DSRequest, but seems to be ignored in the answer. (See the attachments in thread starter post.)

        The criteria in the DSRequest (generated by the ListGrid on searching) looks like this:

        Code:
            criteria:{
                DATA_SAVER_GROUP_ID:[
                    "_szolorg_admin_",
                    "_szolorg_dev_wizards_"
                ],
                _constructor:"AdvancedCriteria",
                operator:"and",
                criteria:[
                    {
                        fieldName:"DATA_NAME",
                        operator:"iContains",
                        value:"vál"
                    }
                ]
            },
        ... but checking the generated SQL query (see in the log), the first criterion (about filed DATA_SAVER_GROUP_ID) does not show up.

        This makes me think that the above criteria is not parsed by the SQL backend as it should be.... which might be because the criteria is not valid.
        (Although it was generated not by me, buy the ListGrid itself, when searching.)
        Last edited by csillag; 19 Mar 2010, 15:25.

        Comment


          #5
          Originally posted by Isomorphic
          If you are trying to enforce fixed criteria, that should be done server-side, for example, use a DMI that modifies the DSRequest. See the "User-Specific Data" example.
          OK, let's suppose I want to do this propery, on the server side. (Despite the fact that I have zero time to spend on this now.)
          (But please answer my question from the previous post, too.)

          How can I compose such a criteria on the server side which contains
          - substring searches for the string coming from the client
          - exact searches set on the server?

          I am aware of the User-specific data example; the only unclear part is how to manage
          the generic and field-level textmatch style (and other advanced criteria-related magic) on the JAVA client and JAVA server side.

          Comment


            #6
            The AdvancedCriteria format is covered here and the rules for translation to Java Collections here. So just modify the criteria to suit - this is easier than other approaches.

            The criteria structure you showed before is basically malformed, and looks like an incorrect attempt at merging simple Criteria and AdvancedCriteria. There is a DataSource API combineCriteria() that does it properly, but it won't have a wrapper for another 2 weeks or so. You can either call it via JSNI or do the merge yourself.

            Comment


              #7
              Originally posted by Isomorphic
              The criteria structure you showed before is basically malformed, and looks like an incorrect attempt at merging simple Criteria and AdvancedCriteria. There is a DataSource API combineCriteria() that does it properly, but it won't have a wrapper for another 2 weeks or so. You can either call it via JSNI or do the merge yourself.
              Thank you for confirming that the shown criteria is invalid.
              But as I have said, this is not something I came up with; this was generated automatically by the ListGrid, when the user has entered something into the filter box.

              Could it be that when preparing the criteria, ListGrid is not calling this DataSource's combineCriteria() you have mentioned? It seems to assume that all the involved criteria are simple Criteria, even thought the advanced ones are generated by the ListGrid itself, in response to the operationIds I have configured for the fields, via ListGridField.filterEditorProperties({operator:"iContains"})
              Last edited by csillag; 19 Mar 2010, 21:25.

              Comment


                #8
                Can you show code that would cause the ListGrid to issue criteria like this?

                Comment


                  #9
                  Well, my code sure does, but it's kind of complicated.
                  Will try to create a standalone example.

                  Comment


                    #10
                    SmartClient 7.0RC2: missing combineCriteria in client js

                    I'm using the SmartClient 7.0RC2 js client lib, and according to DOC, the datasource has a function called combinecriteria, but got error when try to call the method.

                    Thanks,
                    Yan

                    Comment


                      #11
                      Originally posted by yz742000
                      I'm using the SmartClient 7.0RC2 js client lib, and according to DOC, the datasource has a function called combinecriteria, but got error when try to call the method.

                      Thanks,
                      Yan

                      More details:

                      the errors says that function doesn't exist for datasource object.

                      Comment


                        #12
                        It was incorrectly doc'd as an instance method. It's actually a class method, invoked at isc.DataSource.combineCriteria(crit1, crit2).

                        Comment

                        Working...
                        X