Announcement

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

    MFilterBuilder: How to customize the setTextatchStyle of a ComboxItem

    Hi ,

    I have a question regarding FilterBuilder. First, I would like to describe briefly the application.

    I have built a visual query builder for toxicological data. This visual query builder generates a SPARQL query. The generation of SPARQL was, surprisingly, easy to code. There is a screenshot attached to this post. On the screenshot, you can see a ComboxItem. There is something amazing about this combobox: there are 143,372 entries in the valueMap of this combobox and it runs perfectly smoothly!!!

    To have comboboxes in the FilterBuilder, I customized the fields of the datasource as shown below:
    Code:
    ComboBoxItem comboBoxItemWithSubStringMatch = new ComboBoxItem();
    comboBoxItemWithSubStringMatch.setTextMatchStyle(TextMatchStyle.SUBSTRING);
    
    
    DataSourceTextField hispathologyFindingsField = new DataSourceTextField("HistopatologyFinding", "Histopatology finding");
    hispathologyFindingsField.setEditorType(comboBoxItemWithSubStringMatch);

    TextMatchStyle.SUBSTRING of the combobox is ideal when I select "contains" as an operator in the filterbuilder. But now, if I would select "starts with" as the operator, I would like to have TextMatchStyle.STARTS_WITH for the combobox. Also, for the operator "ends with", I would like to have TextMatchStyle.ENDS_WITH, which does not exist, but that is another story.

    So, my question is, how could I dynamically change the TextMatchStyle of my combobox when the user changes the operator?


    I am using SmartGWT 3.1 LGPL.

    Bruno
    Attached Files

    #2
    This would be fairly complex to do and overall we wouldn't recommend doing it - the user may not understand what's going on when the ComboBox switches modes.

    However, if you wanted to attempt it, you would add a FilterChangedHandler to the FilterBuilder and notice a change in the operatorId for the Criterion generated for the field that has the comboBox, and store this new operatorId. Then you'd add a pickListFilterCriteriaFunction to the ComboBox that would use the stored operatorId when returning criteria.

    Comment


      #3
      Originally posted by Isomorphic View Post
      This would be fairly complex to do and overall we wouldn't recommend doing it - the user may not understand what's going on when the ComboBox switches modes.

      However, if you wanted to attempt it, you would add a FilterChangedHandler to the FilterBuilder and notice a change in the operatorId for the Criterion generated for the field that has the comboBox, and store this new operatorId. Then you'd add a pickListFilterCriteriaFunction to the ComboBox that would use the stored operatorId when returning criteria.

      Thank you for your quick reply. I have spent a day trying many things without success. The difficulty I am facing is to get the individual FormItem instance used by my FilterBuilder.

      I tried to override the method getValueFieldProperties using a custom subclass:
      Code:
      public class CustomFilterBuilder extends FilterBuilder {
      	@Override
          public  FormItem getValueFieldProperties(FieldType type, String fieldName, OperatorId operatorId, ValueItemType itemType, String fieldType) {
          	FormItem result = super.getValueFieldProperties(type, fieldName, operatorId, itemType, fieldType);
          	System.out.println("  result: "  + result); //result is always null
          	
          	if(result != null) {
          		//customize the form item
          	}
          	return result;
          
          }
      }
      Unfortunately, getValueFieldProperties always returns null. I wonder if this is a bug? I used the showcase example with the world data source (WorldXmlDS.java).


      Bruno

      Comment


        #4
        Take another look at our suggested approach. It would not involve getValuesFieldProperties(), and overriding this method in general wouldn't make sense.

        Comment

        Working...
        X