Announcement

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

    SelectItem setAllowEmptyValue behaviour change SmartGWT 4.1 to 5.0

    I have a SelectItem that is behaving differently after upgrading to SmartGWT 5.0p.

    The previous 4.1p would show the empty value in the drop down to select showing the configured display value of "--NONE--". In 5.0p this selection is not there so once you select an item in the list, there is no way to select an empty or no value.

    Attached are screen shots of it working in 4.1 and then the same code compiled with 5.0.

    Code levels used:

    SmartClient Version: v9.1p_2015-02-07/Pro Deployment (built 2015-02-07)

    SmartClient Version: v10.0p_2015-05-07/Pro Deployment (built 2015-05-07)

    Here is the code to reproduce it:
    Code:
    public class Sandbox1 implements EntryPoint {
        private static final String ID = "id";
        private static final String PINNED = "pinned";
        private static final String VISIBILITY = "visibility";
        private static final String NAME = "name";
    
        private ListGridRecord[] cacheData = new ListGridRecord[3];
        private DataSource dataSource;
        private SelectItem selectList;
    
        @Override
        public void onModuleLoad() {
    
            int i = 0;
            cacheData[i] = new ListGridRecord();
            cacheData[i].setAttribute(ID, i);
            cacheData[i].setAttribute(NAME, "abc");
            cacheData[i].setAttribute(VISIBILITY, "Me");
            cacheData[i].setAttribute(PINNED, false);
            i++;
            cacheData[i] = new ListGridRecord();
            cacheData[i].setAttribute(ID, i);
            cacheData[i].setAttribute(NAME, "lmn");
            cacheData[i].setAttribute(VISIBILITY, "Group");
            cacheData[i].setAttribute(PINNED, false);
            i++;
            cacheData[i] = new ListGridRecord();
            cacheData[i].setAttribute(ID, i);
            cacheData[i].setAttribute(NAME, "xyz");
            cacheData[i].setAttribute(VISIBILITY, "Everyone");
            cacheData[i].setAttribute(PINNED, false);
    
            final VLayout appLayout = new VLayout();
            appLayout.setWidth100();
            appLayout.setHeight100();
    
            createDataSource();
            createSelectList();
            loadData();
    
            appLayout.setMargin(5);
            appLayout.setMembersMargin(5);
            DynamicForm form = new DynamicForm();
            form.setItems(selectList);
            appLayout.addMembers(form);
            appLayout.draw();
        }
    
        private void createDataSource() {
            dataSource = new DataSource();
            DataSourceField filterIdField = new DataSourceField(ID, FieldType.TEXT, "ID");
            filterIdField.setPrimaryKey(true);
            DataSourceField filterNameField = new DataSourceField(NAME, FieldType.TEXT, "Name");
            DataSourceField visibilityField = new DataSourceField(VISIBILITY, FieldType.TEXT, "Visible To");
            DataSourceField pinnedField = new DataSourceField(PINNED, FieldType.BOOLEAN, "Pinned");
            dataSource.setFields(filterIdField, filterNameField, visibilityField, pinnedField);
            dataSource.setClientOnly(true);
        }
    
        private void createSelectList() {
            selectList = new SelectItem("test");
            selectList.setWidth(300);
            selectList.setAllowEmptyValue(Boolean.TRUE);
            selectList.setEmptyDisplayValue("-- NONE --");
            selectList.setOptionDataSource(dataSource);
            selectList.setTitle("Test");
            selectList.setFilterLocally(Boolean.TRUE);
            selectList.setCachePickListResults(Boolean.FALSE);
            ListGridField filterNameField = new ListGridField(NAME);
            filterNameField.setShowHover(Boolean.TRUE);
            ListGridField visibilityField = new ListGridField(VISIBILITY);
            ListGridField pinnedField = new ListGridField(PINNED);
            selectList.setPickListFields(filterNameField, visibilityField, pinnedField);
            selectList.setValueField(ID);
            selectList.setDisplayField(NAME);
            selectList.setSortField(NAME);
            selectList.setPrompt("Select Filter to use");
            selectList.setShowTitle(Boolean.FALSE);
            selectList.setWrapTitle(Boolean.FALSE);
        }
    
        public void loadData() {
            dataSource.setCacheData(cacheData);
        }
    
    }
    Attached Files

    #2
    Just a note to let you know this is being looked at. We will respond with further information when we have it.

    Regards
    Isomorphic Software

    Comment


      #3
      And - we've now found a fix. Please try the next nightly build, dated May 14 or above.

      Regards
      Isomorphic Software

      Comment


        #4
        What code base is this fixed in?

        I just tried SmartClient Version: v10.0p_2015-05-19/Pro Deployment (built 2015-05-19) and I still have the same problem.

        Comment


          #5
          It works partially I just found. I will look further.. basically when the data is loaded it works, but when new rows are added it breaks.

          I will post update later....

          Comment


            #6
            In the updated sample, click the Add button or Select a value and click the Update button. You will see the NONE option disappear from the list.

            Code:
            public class Sandbox1 implements EntryPoint {
                private static final String ID = "id";
                private static final String PINNED = "pinned";
                private static final String VISIBILITY = "visibility";
                private static final String NAME = "name";
            
                private ListGridRecord[] cacheData = new ListGridRecord[3];
                private DataSource dataSource;
                private SelectItem selectList;
                private int id = 0;
            
                @Override
                public void onModuleLoad() {
            
                    cacheData[id] = new ListGridRecord();
                    cacheData[id].setAttribute(ID, id);
                    cacheData[id].setAttribute(NAME, "abc");
                    cacheData[id].setAttribute(VISIBILITY, "Me");
                    cacheData[id].setAttribute(PINNED, false);
                    id++;
                    cacheData[id] = new ListGridRecord();
                    cacheData[id].setAttribute(ID, id);
                    cacheData[id].setAttribute(NAME, "lmn");
                    cacheData[id].setAttribute(VISIBILITY, "Group");
                    cacheData[id].setAttribute(PINNED, false);
                    id++;
                    cacheData[id] = new ListGridRecord();
                    cacheData[id].setAttribute(ID, id);
                    cacheData[id].setAttribute(NAME, "xyz");
                    cacheData[id].setAttribute(VISIBILITY, "Everyone");
                    cacheData[id].setAttribute(PINNED, false);
                    id++;
            
                    final VLayout appLayout = new VLayout();
                    appLayout.setWidth100();
                    appLayout.setHeight100();
            
                    createDataSource();
                    createSelectList();
                    loadData();
            
                    IButton btnAdd = new IButton("Add Row");
                    btnAdd.addClickHandler(new ClickHandler() {
                        @Override
                        public void onClick(ClickEvent event) {
                            ListGridRecord lgr = new ListGridRecord();
                            lgr.setAttribute(ID, id);
                            lgr.setAttribute(NAME, "Button Add - " + System.currentTimeMillis());
                            lgr.setAttribute(VISIBILITY, "Everyone");
                            lgr.setAttribute(PINNED, false);
                            dataSource.addData(lgr);
                            selectList.setValue(id);
                            id++;
                        }
                    });
            
                    IButton btnUpdate = new IButton("Update Selected");
                    btnUpdate.addClickHandler(new ClickHandler() {
                        @Override
                        public void onClick(ClickEvent event) {
                            ListGridRecord lgr = selectList.getSelectedRecord();
                            if (lgr != null) {
                                lgr.setAttribute(NAME, "Button Update - " + System.currentTimeMillis());
                                dataSource.updateData(lgr);
                            }
                        }
                    });
            
                    appLayout.setMargin(5);
                    appLayout.setMembersMargin(5);
                    DynamicForm form = new DynamicForm();
                    form.setItems(selectList);
                    appLayout.addMembers(form, btnAdd, btnUpdate);
                    appLayout.draw();
                }
            
                private void createDataSource() {
                    dataSource = new DataSource();
                    DataSourceField filterIdField = new DataSourceField(ID, FieldType.TEXT, "ID");
                    filterIdField.setPrimaryKey(true);
                    DataSourceField filterNameField = new DataSourceField(NAME, FieldType.TEXT, "Name");
                    DataSourceField visibilityField = new DataSourceField(VISIBILITY, FieldType.TEXT, "Visible To");
                    DataSourceField pinnedField = new DataSourceField(PINNED, FieldType.BOOLEAN, "Pinned");
                    dataSource.setFields(filterIdField, filterNameField, visibilityField, pinnedField);
                    dataSource.setClientOnly(true);
                }
            
                private void createSelectList() {
                    selectList = new SelectItem("test");
                    selectList.setWidth(300);
                    selectList.setAllowEmptyValue(Boolean.TRUE);
                    selectList.setEmptyDisplayValue("-- NONE --");
                    selectList.setOptionDataSource(dataSource);
                    selectList.setTitle("Test");
                    selectList.setFilterLocally(Boolean.TRUE);
                    selectList.setCachePickListResults(Boolean.FALSE);
                    ListGridField filterNameField = new ListGridField(NAME);
                    filterNameField.setShowHover(Boolean.TRUE);
                    ListGridField visibilityField = new ListGridField(VISIBILITY);
                    ListGridField pinnedField = new ListGridField(PINNED);
                    selectList.setPickListFields(filterNameField, visibilityField, pinnedField);
                    selectList.setValueField(ID);
                    selectList.setDisplayField(NAME);
                    selectList.setSortField(NAME);
                    selectList.setPrompt("Select Filter to use");
                    selectList.setShowTitle(Boolean.FALSE);
                    selectList.setWrapTitle(Boolean.FALSE);
                }
            
                public void loadData() {
                    dataSource.setCacheData(cacheData);
                }
            
            }
            Code Base: SmartClient Version: v10.0p_2015-05-19/Pro Deployment (built 2015-05-19)

            Comment


              #7
              Any updates on this?

              Comment


                #8
                Has anyone had a chance to look at this yet?

                Comment


                  #9
                  This is being worked on. We see the problem and the cause but don't yet have a solution. We'll let you know when we have a fix

                  Regards
                  Isomorphic Software

                  Comment


                    #10
                    Thank You Kindly.

                    Comment


                      #11
                      We've now made a change which we believe will handle this.
                      Please try the next nightly build, dated May 28 or above

                      Regards
                      Isomorphic Software

                      Comment


                        #12
                        Works great, thanks.

                        Comment


                          #13
                          Found several problems with the changes put in on the 28th build.

                          Run the latest sample code posted in this thread:

                          1) Upon loading (and on each "Add Row" button click) the follow warning appears:
                          Code:
                          19:06:04.095:TMR1:WARN:Log:TypeError: _1 is undefined
                          Stack from error.stack:
                              SelectItem._adjustFilteredData() @ sandbox1/sc/modules/ISC_Forms.js:1818:107
                              .makePickList/_13.filterLocalData() @ sandbox1/sc/modules/ISC_Forms.js:1619:102
                              ResultSet.updateCache() @ sandbox1/sc/modules/ISC_DataBinding.js:1926:111
                              ResultSet.handleUpdate() @ sandbox1/sc/modules/ISC_DataBinding.js:1920:1
                              ResultSet.dataSourceDataChanged() @ sandbox1/sc/modules/ISC_DataBinding.js:1917:1
                              anonymous() @ sandbox1/sc/modules/ISC_Core.js line 76 > Function:2:1
                              thunk() @ sandbox1/sc/modules/ISC_Core.js:324:25
                              observation() @ sandbox1/sc/modules/ISC_Core.js:321:375
                              DataSource.updateCaches() @ sandbox1/sc/modules/ISC_DataBinding.js:507:1
                              [c]DataSource.handleUpdate() @ sandbox1/sc/modules/ISC_DataBinding.js:295:150
                              DataSource.fireResponseCallbacks() @ sandbox1/sc/modules/ISC_DataBinding.js:729:445
                              DataSource._completeResponseProcessing() @ sandbox1/sc/modules/ISC_DataBinding.js:728:1
                              DataSource._handleClientOnlyReply/_6() @ sandbox1/sc/modules/ISC_DataBinding.js:589:243
                              DataSource._handleClientOnlyReply() @ sandbox1/sc/modules/ISC_DataBinding.js:590:69
                              [c]Class.fireCallback() @ sandbox1/sc/modules/ISC_Core.js:290:46
                              [c]Class.fireCallback() @ sandbox1/sc/modules/ISC_Core.js:358:286
                              anonymous() @ sandbox1/sc/modules/ISC_DataBinding.js:1686:74
                              com_smartgwt_client_SmartGwtEntryPoint_init__V/$wnd.isc.RPCManager.fireReplyCallback() @ sandbox1/A2E4D3318CBE591035012039F83168C1.cache.html:3073:14
                              [c]RPCManager.fireReplyCallbacks() @ sandbox1/sc/modules/ISC_DataBinding.js:1693:115
                              [c]RPCManager.performOperationReply() @ sandbox1/sc/modules/ISC_DataBinding.js:1684:8
                              RPCManager._performTransactionReply() @ sandbox1/sc/modules/ISC_DataBinding.js:1664:1
                              [c]Class.fireCallback() @ sandbox1/sc/modules/ISC_Core.js:290:46
                              Timer._fireTimeout() @ sandbox1/sc/modules/ISC_Core.js:1291:217
                              Timer.setTimeout/_6<() @ sandbox1/sc/modules/ISC_Core.js:1289:30
                          2) Click the "Add Row" button after the page is loaded and the SelectItem just shows "Loading...". You can click the drop down and see the added row but it does not get selected.

                          3) Continue to click the "Add Row" button and after maybe 1 or 2 times, the display value, in this case, "name" no longer is what is displayed in the SelectItem but rather the numeric ID is shown (5, 6, 7). If you click the drop down you will see the actual name and not the ID.

                          See attached images.

                          Same sample works fine on:
                          SmartClient Version: v10.0p_2015-05-10/Pro Deployment (built 2015-05-10)
                          &
                          SmartClient Version: v10.0p_2015-05-27/Pro Deployment (built 2015-05-27)

                          But the above behavior appears in this build:
                          SmartClient Version: v10.0p_2015-05-28/Pro Deployment (built 2015-05-28)
                          &
                          SmartClient Version: v10.0p_2015-05-31/Pro Deployment (built 2015-05-31)
                          Attached Files
                          Last edited by stonebranch1; 1 Jun 2015, 15:22.

                          Comment


                            #14
                            Any updates on this?

                            Comment


                              #15
                              It's in progress. We'll update the thread when we have any updates for you.

                              Comment

                              Working...
                              X