Announcement

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

    Advanced Filter Builder questions

    My application is using a AFB against a DataSource with over 280 fields. Is there a (easy) way to have the fieldname droplist display an ever narrowing list of fields as the user types additional characters of the desired field name?

    I've tried unsuccessfully to add a search operator using the .addSearchOperator method. Would you please point me to a working example that accomplishes that? (The datasource is built server-side from a dynamically created XML string.) Since I process the AFB using the JSON encode of the AFB, I only need it to supply the new operator in the criteria object that I parse server side.

    Are validators operable in the AFB? I'd like to validate the search value to a list of regex expressions. If not, could field values be validated server side and have it return validation results to the AFB?

    I also have date fields that need to support a variety of input formats in addition to the default format. AFB ignores the criteria (in the if the date value field doesn't match its expected format. I could tell AFB it's a text field and convert it server-side, but I loose the date-picker widget in the bargain. Can I have the date-picker and relative-date droplists appear for text fields?

    BTW, I'm using SmartGWT 2.3Pro
    Last edited by bill.erskine; 2 Nov 2010, 10:57.

    #2
    This sample shows how you can provide a FilterBuilder with a large, dynamically fetched set of field definitions.

    Take a look, and see if it also makes it clear how to solve your other questions - it's not clear if you will still have a reason for a custom search operator or your other requests once you see the approach shown in the sample.

    Comment


      #3
      The sample you pointed me to gave me that hint that I needed for getting FilterBuilder to show a combobox like field list.

      Here's the code that will do that for anybody who's interested:
      Code:
              SelectItem formItemProperties = new SelectItem();
              formItemProperties.setShowPickerIcon(true);  // show the drop-arrow
              formItemProperties.setAddUnknownValues(false);  // only fields in the list
              formItemProperties.setType("comboBox");  // combobox look-n-feel
              formItemProperties.setWidth(200);  // wide enough for my field names
              filterBuilder.setFieldPickerProperties(formItemProperties);
      My next need is to have date fields that support a variety of input formats in addition to the default format. AFB ignores the criteria (if the date value field doesn't match its expected format.) Ideally, I'd like to have it support multiple date formats (converting to default display style is OK).

      A workable alternative would be to make it a text field and convert it server-side, but I'd loose the date-picker widget in the bargain. Can I have the date-picker and relative-date droplists appear for text fields?

      I tried adding the following to my DS xml definition:
      Code:
      ...
      <types>
        <type ID="textdate" inheritsFrom="text" editorType="date" />
      </types>
      <fields>
      ...
      But it didn't work. Any ideas?

      Comment


        #4
        How do you mean that you want to support a variety of date formats? If what you're trying to achieve is just ordinary localization, you can use APIs on DataUtil to set the system-wide data input and display formats.

        Comment


          #5
          Our users will be using the FilterBuilder to create search criteria for a large datasource (not SQL).
          For date fields, they need to be able to enter dates in mm/dd/yyyy format (US locale) plus ddMMMyyyy (25DEC2010), yyyy-MM-dd (2010-12-25) and yyyyMMdd (20101225). These are typically being cut/paste from source documents where they appear any of those formats. Multiple formats may be used in the same FilterBuilder.

          One other juicy requirement is to support entering just a 4-digit year and have it interpreted as between 01-01-yyyy to 12-31-yyyy.

          They've seen FilterBuilder and love the date-picker and relative date functionality but also need to paste in dates in the above formats. It's OK if they get converted to the locale format. Currently if you enter a non-locale date format, the criteria is omitted from the resulting JSON criteria object.

          Our fallback method is to treat date fields as text fields in FilterBuilder and validate and parse the various date input formats when we build the resulting search request server-side. But we loose the date-picker/droplists in the process.

          Any ideas ?

          Comment


            #6
            Any reply forthcoming Isomorphic?

            Comment


              #7
              Hi Bill,

              We've looked this over - superficially, the combination of DataSourceField.setEditorType() and the FormItemValueParser API gives you a place to do your own date parsing and support the variety of different formats you want to support. However, looking deeper, you don't necessary know whether, when your parser is invoked, you're in a normal FilterBuilder value field, or in start and end fields shown for a between operator, and this is important for your use case because it affects how you'd interpret YYYY values. Nor would your custom editorType be used by the RelativeDateItem as things stand. So to do this right would require a number of small enhancements.

              What we'd recommend is using the Feature Sponsorship program to have Isomorphic build your exact use case, adding new APIs as necessary to make it work fully.

              Comment

              Working...
              X