Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

[BUG] SelectItem doesn't keep selected values after filtering

$
0
0
SmartClient Version: v9.1p_2014-08-05/LGPL Development Only (built 2014-08-05) in Firefox 26 for developement purpose only. Tested compiled against lastest versions

Configured a selectItem with listGridProperties to enable filtering and sorting and setting multiple is true, if you select a row and then filter and select another row, the previous selection it's replaced with the new one. But then if you clean the filter and select a another row, both selections are kept. Selection is kept only when clearing the filter

In preovious post you said that is a common issue in client-only dataSources. This happens with normal dataSources too

TestCase
Code:

DynamicForm dynamicForm = new DynamicForm();

// ListGrid para cuando se despliega el selectItem de Pais
ListGrid paisListGridProperties = new ListGrid();
paisListGridProperties.setShowFilterEditor(true);
paisListGridProperties.setCellHeight(25);
paisListGridProperties.setShowHeader(true);
ListGridField idField = new ListGridField("id", "Id");
idField.setHidden(true);
ListGridField nameField = new ListGridField("name", "Name");
paisListGridProperties.setFields(idField, nameField );
paisListGridProperties.setSortField("name");

SelectItem paisesComboBoxItem = new SelectItem("country", "Country");
paisesComboBoxItem.setTitleOrientation(TitleOrientation.TOP);
paisesComboBoxItem.setEmptyDisplayValue("Empty");
paisesComboBoxItem.setOptionDataSource(TestDS.getInstance());
paisesComboBoxItem.setValueField("id");
paisesComboBoxItem.setDisplayField("name");
paisesComboBoxItem.setPickListProperties(paisListGridProperties);
paisesComboBoxItem.setMultiple(true);
paisesComboBoxItem.setMultipleAppearance(MultipleAppearance.PICKLIST);

dynamicForm.setItems(paisesComboBoxItem);

dynamicForm.draw();

TestDS
Code:

public static class TestDS extends DataSource {

private static TestDS instance = null;

        public static TestDS getInstance() {
                if (instance == null) {
                        instance = new TestDS("testDS");
                }

                return instance;
        }

        public TestDS(String idDataSource) {
                super();

                // Establecer Id del DataSource
                setID(idDataSource);
                setDataFormat(DSDataFormat.JSON);
                setDataURL("test.js");

                // ID
                DataSourceIntegerField id = new DataSourceIntegerField("id", "Id");
                id.setPrimaryKey(true);

                // Código
                DataSourceTextField name = new DataSourceTextField("name", "Name");

                // Asignar campos al Data Source
                setFields(id, name);
        }

}

test.js
Code:

[
        {
                id : 0,
                name : "Spain"
        },
        {
                id : 1,
                name : "United Kingdom"
        },
        {
                id : 2,
                name : "USA"
        },
        {
                id : 3,
                name : "Japan"
        }
]

Old related post => http://forums.smartclient.com/showth...427#post122427

Best regards

Viewing all articles
Browse latest Browse all 4756

Trending Articles