Announcement

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

    ListGrid setShowFilterEditoris not working as expected. Help Needed

    Hi guys, after few devastating research I am here to as a question. I have set the value setShowFilterEditor to true here and
    Code:
    grid.setShowFilterEditor(Boolean.TRUE)
    grid.setFilterEditorCriteria(new Criteria("userName", "SomeName"));
    I was expecting I will get SomeName in userName filter editor, but it is not populated.

    If I do
    Code:
    grid.setCriteria(new Criteria("userName", "SomeName"));
    it works, but I do not want to do it since we hided native filter button, instead exposed server side filtering by our code. Since there is not filter button clicked
    Code:
    grid.getCriteria()
    and
    Code:
    grid.getFilterEditorCriteria()
    both are returning different criteria objects. If user removes some values from filter and click a our refresh button still
    Code:
     grid.getCriteria()
    has old criteria clauses. Then I tried to disable client side filtering with following code which did not work either.

    Code:
    ResultSet resultSetProperties = new ResultSet();
    resultSetProperties.setUseClientFiltering(false);
    grid.setDataProperties(resultSetProperties);
    Is there any way to set filter editor value in filter editor programmatically thru grid.getFilterEditorCriteria()? Or is there any way of forsing grid not to filter but enable filter editor?
    This has been driving me crazy.
    Thanks in advance.

    #2
    We're not seeing a general problem with setFilterEditorCriteria() - it behaves as expected.

    Your code may be setting criteria for the filter editor, then immediately wiping it out, for example, by calling fetchData() with no arguments (implying no criteria).

    If you instead think this API is malfunctioning, try to put together a minimal, ready-to-run test case demonstrating the problem.

    Comment


      #3
      Thanks for your reply.
      Based on java doc grid.setShowFilterEditor(Boolean.TRUE):
      * Should this listGrid display a filter row. If true, this ListGrid
      * will be drawn with a single editable row, (separate from the body) with a filter button.
      1. I was expecting this grid.setFilterEditorCriteria(new Criteria("userName", "SomeName")); would set value to filter so user can see it, but it is not happening.
      2. Is this right approach to disable filtering?
      Code:
      ResultSet resultSetProperties = new ResultSet();
      resultSetProperties.setUseClientFiltering(false);
      grid.setDataProperties(resultSetProperties);
      Thanks.

      Comment


        #4
        1. see previous response
        2. that will disable client-side filtering, which causes a large loss in performance (see Adaptive Filter sample) and seems totally unrelated to your problem.

        Comment


          #5
          1. We use setAutoFetchData(true); and always do filter on server side and set data with dataSource.setCacheData().
          2. We do it on the server side to get instant values, We do not want to do on the client side. Ultimately I want to bypass client side filtering while using filter editor, so I can grab its values and do filter on the server side.

          One more thing to note also I do not use native filter button, that button is disabled and I use custom form button to filter. So native filter button is never clicked.

          Does it make sense?

          Thanks.
          Last edited by elber.kam@gmail.com; 22 Dec 2015, 13:06.

          Comment


            #6
            1. see first response - the method behaves as expected in our testing, so we need to see a test case
            2. that code is correct for disabling client-side filtering. You should carefully consider whether this makes sense, as again, there are tremendous performance benefits to performing filtering on the client.

            Comment


              #7
              Hi elber.kam@gmail.com,

              what is the field-definition in your .ds.xml of the field where you expect the "someName" to show up in the filterRow?

              If it is more complicated than a "normal" text-field (unlikely), did you see FormItem.setCriterionSetter()?
              I'd assume that what you need is:
              1. ListGrid with setShowFilterEditor(true)
              2. Visible/Not Hidden ListGridField for "userName"
              3. myListGrid.fetch() with Criteria for "userName" (no setFilterEditorCriteria())
              What do you mean by "it works, but I do not want to do it since we hided native filter button, instead exposed server side filtering by our code. Since there is not filter button clicked"?

              Any (additional) serverside filtering you apply will obviously not be visible on the client. See the Developer Console's RPC Tab for the server response.

              Best regards
              Blama

              Comment


                #8
                Thanks guys for jumping onto this

                One more thing to note also I do not use native filter button, that button is disabled and I use custom form button to filter. So native filter button is never clicked.
                I said it work with this code `grid.setCriteria(new Criteria("userName", "SomeName"));`. it means when I run this code before calling redraw() method on grid it sets SomeName as a value to grid field editor(value Elbek is set here):



                As you see user name field is filled. So this is doing the job. But I do not do this because this value remains as a part of criteria(I can see it when I do grid.getCriteria().values()) even after user removes it from filter editor . I think the reason is because user is not clicking native filter button. So new data will not be shown even if user name filter is empty, because internally it is still there. So I was hoping to set this value using grid.getFilterEditorCriteria() which I was not able to.

                I hope I made it clear.

                Comment


                  #9
                  The problem was clear from your first statement, however, once again, we don't see this problem in our tests. Something is different or unusual about your code, and we need a minimal, ready-to-run test case replicating the problem if we are going to look further.

                  Comment


                    #10
                    Well, I don't understand the use case yet. You say what is shown in the picture is correct. What is happening next?

                    The user removes the "ELBEK" from the filterRow? What then? Does he press enter? Does he press your "Filter" button? What is expected then?

                    Best regards
                    Blama

                    Comment


                      #11
                      After user removes ELBEK and clicks Filter button(on top of the grid as shown in the picture), Filter button triggers the logic where I should read filter editor values and go to server to get data. I read filter editor values as following:
                      grid.getCriteria().getValues() which returns map. But map still contains ELBEK as a part of criteria. I figured I can to use this grid.getFilterEditorCriteria() to get user entered data, for example user entered data as JOHN(after clearing ELBEK value) for userName. I can go to server and get the data from server for JOHN but when I do dataSource.setCacheData(data); it does not show up in grid, since grid.getCriteria() still has ELBEK as a criteria value. So I was thinking to bypass client side filtering but having filter editor in place, and above code to bypass did not work either.

                      Comment


                        #12
                        Did you try building the new criteria on press of your filter button with grid.getFilterEditorCriteria() and then instead of doing whatever you are doing to get/apply the new data do grid.fetch(yourNewCrit)?
                        Using listgrid.fetch() will update the grid's criteria.

                        How do you currently get the data and why do you do dataSource.setCacheData(data)?

                        Comment


                          #13
                          We never do client side filter, so always when filter is clicked I go to server to get data and do dataSource.setCacheData(data). I never do fetch manually, it is auto fetch true.

                          Comment


                            #14
                            OK, then try my grid.fetch(yourNewCrit) suggestion and let us know how it works. Should also be less code than your current approach.

                            Comment


                              #15
                              Hi Blama.
                              There is no such method grid.fetch(yourNewCrit). Maybe I am on older version. smartgwt.jar file does not contain version entry in manifest file.
                              Anyways I was able to get by using this:

                              FormItem formItem = new FormItem();
                              formItem.setValue("ELBEK");
                              grid.getField("userName").setFilterEditorProperties(formItem);

                              But it has some problems is coming up which I am working on.

                              Sorry for late response.

                              Thanks.
                              Last edited by elber.kam@gmail.com; 23 Dec 2015, 08:07.

                              Comment

                              Working...
                              X