Announcement

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

  • swatiagarwal
    replied
    Thank you Blama. I used the second approach. It worked.

    Leave a comment:


  • Blama
    replied
    Well, you have to return the Criterion from the methods you are required to implement.
    I did something here:
    Code:
            setCriterionGetter(new FormItemCriterionGetter() {
                @Override
                public Criterion getCriterion(DynamicForm form, FormItem item, TextMatchStyle textMatchStyle) {
                    return this.getCriterion(form, item);
                }
    
                @Override
                public Criterion getCriterion(DynamicForm form, FormItem item) {
                    SelectItem si = (SelectItem) item;
                    if (si.getSelectedRecords() != null && si.getSelectedRecords().length > 0) {
                        AdvancedCriteria finalOrCrit = new AdvancedCriteria(OperatorId.OR);
                        for (int i = 0; i < si.getSelectedRecords().length; i++) {
                            String productId = si.getSelectedRecords()[i].getAttributeAsString(DatasourceFieldEnum.T_PRODUCT__ID.getValue());
                            productId = ", " + productId + ",";
                            finalOrCrit.appendToCriterionList(
                                    new Criterion(DatasourceFieldEnum.V_LEAD_PRODUCTLIST__PRODUCTID_LIST_SEP.getValue(), OperatorId.CONTAINS, productId));
                        }
                        return finalOrCrit;
                    } else
                        return null;
                }
            });
    Yours will be significantly more simple (null checks + one line code) because all you need to do is to change the fieldname the criterion uses. Of course the ListGrid data must include the valueField (as normal field, as hidden field or at least as field definition in your .ds.xml).
    Apply this to your TextItem. Then use that TextItem in ListGridField.setEditorProperties().

    Perhaps (I did not use this so far) it is also enough to just use FormItem.setCriteriaField() and let your TextItem point to the valueField instead. The "ListGrid data must include the valueField" applies nevertheless.

    Best regards
    Blama

    Leave a comment:


  • swatiagarwal
    replied
    Hi Blama,

    I am not able to understand how to implement this. Do you have any example. I want the filter to be a textitem and filter data on field values and not on display field that i set in select item as editor type of that field.

    Leave a comment:


  • Blama
    replied
    Hi swatiagarwal,

    see these docs and apply it to the TextItem you use in setFilterEditorType(). Also, I'm using ListGridField.setEditorProperties() instead.

    Best regards
    Blama

    Leave a comment:


  • swatiagarwal
    replied
    Hi
    I am using the same example as above. I have set grid.setShowFilterEditor(true);
    Because i have set display field, the filter appears as selectItem. But i do not want the filter to appear as select item.
    I tried, gridField.setFilterEditorType(new TextItem());
    But in this case the filter does not work because filter functionality works on display field.

    Leave a comment:


  • rajatsingla
    replied
    Thank you so much Blama. This solved my problem.

    Leave a comment:


  • Blama
    replied
    Hi,

    Editing and Displaying is very different.
    Assuming you are using a .ds.xml-backed DataSource:
    1. Add a foreignKey-attribute to you id-field (perhaps with joinType="outer", if it can be null)
    2. Add a new field with includeFrom="parentDS.displayField"
    3. Add a new attribute displayField to the id-field, pointing to the new field from step 2
    You can find all this in the ServerDS docs and also in the Quick Start Guide-PDF.

    Best regards
    Blama
    Last edited by Blama; 31 Jan 2018, 07:06. Reason: typo

    Leave a comment:


  • Select item as editor in ListGridField not displaying proper value

    Hello,

    I am using chrome browser and SmartClient Version: v11.0p_2017-02-11/PowerEdition Deployment (built 2017-02-11)

    I am using ListGrid component. One of list grid field has editor type as select item. In select item there are two pick list field. I am setting display field and value field of select item properly.

    When Grid row is in editable state then proper display value is displayed but when gird is not in editable state it is displaying value field of select item. I want display field should visible everytime.

    Code:

    ListGrid vendorMaterialGrid = new ListGrid();
    ListGridField materialField = new ListGridField("materialCode");
    vendorMaterialGrid.setEditorCustomizer(new ListGridEditorCustomizer() {

    @Override
    public FormItem getEditor(final ListGridEditorContext context) {
    SelectItem materialselectItem = new SelectItem();
    ListGridField materialField = new ListGridField("materialCode");
    materialselectItem.setWidth(200);
    materialField.setWidth(60);
    ListGridField descriptionField = new ListGridField("description");
    descriptionField.setWidth(140);
    materialselectItem.setDisplayField("materialCode");
    materialselectItem.setValueField("descripiton");
    materialselectItem.setPickListFields(materialField, descriptionField);
    return materialselectItem;

    }

    });

    Please help me out.

    Thanks
Working...
X