Announcement

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

    Filtering when using setMultiple(true) and foreign keys.

    SmartClient Version: 8.2/LGPL Development Only (built 2011-12-05)
    Browser: Internet Explorer 9.0.8112.16421

    Issue: I have a ListGrid bound to a RestDataSource (using clientOnly(true) for now). The DataSource declares a field that can contain multiple foreign keys to another table.
    Code:
    // This is in AssignedPartsRestDataSource.
    DataSourceField ataIds = DataSourceField(
        ATA_IDS_COL_NAME,
        FieldType.INTEGER,
        ATA_IDS_TITLE);
    
    ataIds.setCanEdit(true);
    ataIds.setCanFilter(true);
    ataIds.setPrimaryKey(false);
    ataIds.setRequired(true);
    ataIds.setMultiple(true);
    ataIds.setForeignKey(TranAtaNumberRestDataSource.getInstance().formatForeignKey(
            TranAtaNumberRestDataSource.ID_COL_NAME));
    (the formatForeignKey just returns the data source's ID + "." + the column name given).

    In my list grid I have overridden this field so that I can retrieve the display values:
    Code:
    // Override the ATA_IDS field that was declared in the datasource the
    // same way.
    ListGridField ataIdsField = new ListGridField(
        AssignedPartsRestDataSource.ATA_IDS_COL_NAME,
        AssignedPartsRestDataSource.ATA_IDS_TITLE);
    
    ataIdsField.setType(ListGridFieldType.INTEGER);
    ataIdsField.setMultiple(true);
    ataIdsField.setOptionDataSource(TranAtaNumberRestDataSource.getInstance());
    ataIdsField.setAutoFetchDisplayMap(true);
    ataIdsField.setValueField(TranAtaNumberRestDataSource.ID_COL_NAME);
    ataIdsField.setDisplayField(TranAtaNumberRestDataSource.ATA_NO_COL_NAME);
    This works fine. The ID is resolved to the correct string. It even works for multiple entries, correctly resolving each.

    I then have a picklist that allows the user to edit the selection of ATAs. This also seems to work:
    Code:
    SelectItem ataNumberPicklist = new SelectItem(
        AssignedPartsRestDataSource.ATA_IDS_COL_NAME,
        AssignedPartsRestDataSource.ATA_IDS_TITLE);
    
    ataNumberPicklist.setMultiple(true);
    ataNumberPicklist.setOptionDataSource(TranAtaNumberRestDataSource.getInstance());
    ataNumberPicklist.setValueField(TranAtaNumberRestDataSource.ID_COL_NAME);
    ataNumberPicklist.setDisplayField(TranAtaNumberRestDataSource.ATA_NO_COL_NAME);
    
    ListGrid pickListProperties = new ListGrid();
    pickListProperties.setAutoFitFieldsFillViewport(false);
    pickListProperties.setAutoFitWidthApproach(AutoFitWidthApproach.BOTH);
    pickListProperties.setAutoFitFieldWidths(true);
    pickListProperties.setFixedRecordHeights(false);
    pickListProperties.setAlternateRecordStyles(true);
    pickListProperties.setCanResizeFields(true);
    pickListProperties.setCanEdit(false);
    pickListProperties.setWrapCells(true);
    pickListProperties.setOverflow(Overflow.AUTO);
    
    ataNumberPicklist.setPickListProperties(pickListProperties);
    ataNumberPicklist.setPickListWidth(ComposerConstants.PICKLIST_DEFAULT_WIDTH);
    ataNumberPicklist.setTextMatchStyle(TextMatchStyle.SUBSTRING);
    What I can't get working is filtering. I would like to use just a normal TextItem instead of the given picklist to filter. How can I do this? I've tried:
    Code:
    ataIdsField.setFilterEditorType(new TextItem());
    This doesn't seem to work, as the screen just goes blank for a second and then returns all records.

    For example:

    Assume I have part number 123, which has ATAs abc and cde. If I type "c" in the filter box it should show part number 123 (containing the two ATAs) in my list.

    Additionally, it seems that the built-in (default) filter editor doesn't work when you have multiple values, only single values. So when I have part 123 with an ATA of abc, and select abc from the default filter editor it works, but once I add cde to the part the filter editor stops working.

    I'm assuming all of this has something to do with the "setMultiple(true)". Do I have to manually come up with some sort of criteria?

    Thanks for any help!
    Brian
    Last edited by bschrameck; 9 Jul 2012, 09:36.
Working...
X