Announcement

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

    How to find criteria values in SmartGWT 2.4

    We moved from SmartGWT 2.0 to SmartGWT 2.4. We have a filtered listgrid with autofetchdata set to false and filteronkeypress set to true. Some fields are strings, but we have one field as a date.

    So, in executeFetch, this was our previous code:

    Map<String, String> filterMap = DSrequest.getCriteria().getValues().

    This would generate a name/value map that we would send down to our back end. Nice and simple.

    Now, it 2.4, the date field is really a date range. In retrospect, this may be a good thing for our UI. But I am having difficulty working with it. I realize that I am now working with AdvancedCriteria objects, but I can't seem to figure out how to get the names and values out of the object. Using the debugger, I seem to be in an endless loop of HashMaps. I am sure I am missing something.

    #2
    You can see the AdvancedCriteria format in either the server-side control or RPC tab of the Developer Console, or just consult the docs. There's no loops and the structure is straightforward. If you ultimately decide you'd rather not implement support for it, use setFilterEditorType() to set the filter interface back to an ordinary DateItem.

    Comment


      #3
      I am still not quite understanding how to decipher the map properly. So, for instance, I have three fields. "customerId", "productId", and "date". customerId and productId are text fields. date is a date range.

      So, in SmartGWT 2.0, criteria.getValues would give me a map of <"customerId","1">,<"productId","ABC">,<"date","2010-01-01">.

      Now, I am trying to get something like:

      <"customerId","1">,<"productId","ABC">,<"date_begin","2010-01-01">,<"date_end","2010-01-31">

      I understand the structure of the AdvancedCriteria object from the docs. What I don't understand is how to extract this from requestDS.getResultSet().getCriteria().

      Thanks.

      Comment


        #4
        Not sure how we can help.. this is now just a matter of basic Java Collections usage. Again the structure is visible in both client and server-side logs.

        Comment


          #5
          Hi Isomorphic

          You've told:
          If you ultimately decide you'd rather not implement support for it, use setFilterEditorType() to set the filter interface back to an ordinary DateItem.
          but in SmartGWT 2.4 it doesn't work anymore !!!

          I've set up clean project to test this, and I've checked it with SmartGWT 2.1, 2.2, 2.4
          Code:
          ListGrid tab = new ListGrid();
          ListGridField[] fields = {
          	new ListGridField("DATE1", "DATE - setFilterEditorType") {
          		{
          			setType(ListGridFieldType.DATE);
          			setFilterEditorType(new DateItem());
          		}
          	},
          	new ListGridField("DATE2", "DATE - default") {
          		{
          			setType(ListGridFieldType.DATE);
          		}
          	}
          };
          tab.setWidth(600);
          tab.setFields(fields);
          tab.setShowFilterEditor(true);
          
          VLayout vl = new VLayout(10);
          vl.addMember(tab);
          RootPanel.get().add(vl);
          in 2.1 - Filter Editor is simple DateItem() with DatePicker
          in 2.2 - it's Date Range, but setFilterEditorType(new DateItem()) works well
          in 2.4 - previous trick doesn't work anymore - instead of DateItem I have Date Range picker...

          - it's important for me because my project rely on this method.

          So Isomorphic please tell us how to do it.

          Comment


            #6
            Oh that is annoying. Turns out there is a bug with setFilterEditorType() that was causing it to fail here.

            We've now resolved this - try the next nightly build and you should be able to set your filterEditorType to show a DateItem.

            Comment

            Working...
            X