Announcement

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

  • Isomorphic
    replied
    See the docs for setEditorType() / setEditorProperties() - you can't validly switch to a completely different item type via setEditorProperties(). What you've done here is basically created exactly one instance of your two-item DynamicForm and it's being yanked back and forth between different instances of the CanvasItem.

    As far as using setEditorType(), you won't have to create a custom class or use reflection. It would be sufficient to set the editorType to CanvasItem and pass a FormItemInitHandler which creates the DynamicForm.

    However, this whole approach is perhaps a bit off, as you should consider whether you actually want this same interface for every operator.

    Leave a comment:


  • thop
    replied
    Managed to get a version that somewhat works with creating a CanvasItem.
    Click image for larger version

Name:	CurrentVersion.png
Views:	12
Size:	27.3 KB
ID:	259360

    The code I used for the item is:

    Code:
    public class CategorizationFormItem extends CanvasItem {
    
    
        public CategorizationFormItem(List<CategoryTreeBean> categoriesList) {
    
            SelectItem categorizationType = new SelectItem("Type");
    
            LinkedHashMap<Integer, String> categorizations = categoriesList.stream()
                    .collect(Collectors.toMap(CategoryTreeBean::getCategoryID, CategoryTreeBean::getName, (e1, e2) -> e1, LinkedHashMap::new));
            categorizationType.setValueMap(categorizations);
            SelectItem categorizationValues = new SelectItem("Value");
            final DynamicForm dynamicForm = new DynamicForm();
            dynamicForm.setNumCols(4);
            dynamicForm.setItems(categorizationType, categorizationValues);
            setShouldSaveValue(true);
            setCanvas(dynamicForm);
        }
    
    
    }
    And when i create the filter I do the following for the field definition (field.setEditorProperties(new CategorizationFormItem(categoriesList));):

    Code:
    private void createTextField(String name, String title, String... choices) {
        DataSourceField field;
        if (choices.length != 0) {
            field = new DataSourceEnumField(name, title);
            field.setEditorProperties(new CategorizationFormItem(categoriesList));
        } else {
            field = new DataSourceTextField(name, title);
        }
        field.setValidOperators(OperatorId.IEQUALS, OperatorId.INOT_EQUAL, OperatorId.ICONTAINS, OperatorId.BETWEEN_INCLUSIVE);
        setFields(field);
    }

    The issue that is now happening is that I can only have one of the custom attribute filters displayed on the screen. As you can see in the screenshot at the top. If I add a second Category attribute the first one will loose the drop-down lists and if I would add a third one the first two would both be empty (See SS below).
    Click image for larger version

Name:	MissingDropDown.png
Views:	4
Size:	36.7 KB
ID:	259361
    Is there something I am missing in my implementation? Not sure what to try to fix this.

    Leave a comment:


  • thop
    started a topic Custom fields on FilterBuilder

    Custom fields on FilterBuilder

    Hello,

    I am trying to implement an additional drop-down list on the filterbuilder. The goal is to have two drop-down lists where the second one would depend on the first one.

    It should look something like this:
    Click image for larger version

Name:	CustomFilterBuilder.png
Views:	7
Size:	5.5 KB
ID:	259343
    So if I choose Europe in the first drop-down I can select countries that belong to Europe in the second drop-down list.

    I cant seem to find a way to do this in the documentation.
    Is there a possibility to implement a custom form that gets displayed once a specific attribute is selected(continent in the screenshot above)?
    Could you give me an example if its possible or just tell me where in the documentation this is described.
Working...
X