Announcement

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

    Can you specify substring matching for a combobox filter editor in ds.xml?

    I have tested this in the following releases and get the same behavior
    v9.0p_2013-10-10/PowerEdition
    v9.0p_2014-01-29/PowerEdition

    We are using SmartGWT 4.0p from the above build dates.

    I have a listgrid that is created without specifying any fields in java code. All fields are specified in the ds.xml only.

    A few of the fields are foreign key references into other tables and I have those fields configured to use a combobox in the filter editor. Here is one of the field definitions

    Code:
    <field name="buyer" includeFrom="abbuyer.buyer_display" title="Buyer"
     optionDataSource="abbuyer" valueField="buyer_display"
     editorType="ComboBoxItem" optionTextMatchStyle="substring"/>
    When typing a string in the filter editor for that field, the listgrid will correctly filter down the results using a substring match. The filter editor however is performing a startswith search against the possible field values, so the combobox will display "No Items to show". If I type the beginning of a value in the filter editor, the combobox correctly filters down the possible values.

    I've attached a screenshot that shows the listgrid filtered properly, with the filter editor showing no matches.

    How can I modify the ds.xml file to perform a substring match in the filter editor?

    Is the ListGridField javadoc the best place to look for attributes for configuring <field/> elements in the ds.xml?

    Here is the code used to create the ListGrid. This is used to create several ListGrids to be used as admin interfaces into tables, so we don't want to specify any fields in java code.
    Code:
    		DataSource ds = DataSource.get(dataSourceName);
    
    		final ListGrid grid = new ListGrid();
    		grid.setDataSource(ds);
    		grid.setAutoFetchData(true);
    		grid.setCanEdit(true);
    		grid.setCanRemoveRecords(true);
    		grid.setModalEditing(true);
    
            grid.setShowFilterEditor(true);
            grid.setFilterOnKeypress(true);
            grid.setFetchDelay(500);
    
            grid.setMinFieldWidth(65);
    
    	    // Create grid footer (toolstrip) for add button
    		ToolStrip footer = new ToolStrip();
    		footer.setMembersMargin(3);
    		footer.setWidth100();
    		footer.setHeight(24);
    
    		LayoutSpacer spacer = new LayoutSpacer();
    		spacer.setWidth("*");
    		footer.addMember(spacer);
    
    		final ToolStripButton addButton = new ToolStripButton("Add Record", "[SKIN]/actions/add.png");
    		addButton.addClickHandler(new ClickHandler() {
    			@Override
    			public void onClick(ClickEvent event) {
    				grid.startEditingNew();
    			}
    		});
    		footer.addMember(addButton);
    
    		grid.setGridComponents(ListGridComponent.FILTER_EDITOR, ListGridComponent.HEADER, ListGridComponent.BODY, ListGridComponent.SUMMARY_ROW, footer);
    
    		return grid;
    Attached Files
    Last edited by brad_c; 6 Feb 2014, 13:03. Reason: I left out the SmartGWT version

    #2
    Is the ListGridField javadoc the best place to look for attributes for configuring <field/> elements in the ds.xml?
    No, there is specific reference for the valid properties on a <field> in .ds.xml right here.

    You are, in fact, cheating a bit already. Neither optionDataSource nor optionTextMatchStyle is valid on a <field>. The effect of setting these on your field is that they are picked up by any DBC.

    You probably did not want the effect of setting listGridField.optionDataSource (see docs for this property - loads entire dataset up front). It's unclear what you're trying to do here, but please revisit the docs for dataSourceField.includeFrom, as they explain the correct definitions to use for an editable included field.

    As far as startsWith vs substring matching, any way of setting this from the DataSource would be a bit of a hack (DataSources are used by multiple component types). The right approach for this kind of behavior would be to subclass ListGrid such that it notices special, application-specific properties that you've set in your DataSource, and modifies its fields accordingly.

    Comment

    Working...
    X