Announcement

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

    ListGrid - clearEditValue shows unexpected behavior

    Hi Isomorphic,

    please see this testcase:

    Code:
    package com.smartgwt.sample.client;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.core.KeyIdentifier;
    import com.smartgwt.client.util.Page;
    import com.smartgwt.client.util.PageKeyHandler;
    import com.smartgwt.client.util.SC;
    import com.smartgwt.client.widgets.IButton;
    import com.smartgwt.client.widgets.events.ClickEvent;
    import com.smartgwt.client.widgets.events.ClickHandler;
    import com.smartgwt.client.widgets.form.fields.ComboBoxItem;
    import com.smartgwt.client.widgets.grid.ListGrid;
    import com.smartgwt.client.widgets.grid.ListGridField;
    import com.smartgwt.client.widgets.grid.events.ChangedEvent;
    import com.smartgwt.client.widgets.grid.events.ChangedHandler;
    import com.smartgwt.client.widgets.layout.HLayout;
    import com.smartgwt.client.widgets.layout.VStack;
    
    /**
     * Entry point classes define <code>onModuleLoad()</code>.
     */
    public class BuiltInDS implements EntryPoint {
        private ListGrid boundList;
        private IButton editBtn;
    
        /**
         * This is the entry point method.
         */
        public void onModuleLoad() {
            KeyIdentifier debugKey = new KeyIdentifier();
            debugKey.setCtrlKey(true);
            debugKey.setKeyName("D");
    
            Page.registerKey(debugKey, new PageKeyHandler() {
                public void execute(String keyName) {
                    SC.showConsole();
                }
            });
    
            VStack vStack = new VStack();
            vStack.setLeft(175);
            vStack.setTop(75);
            vStack.setWidth("70%");
            vStack.setMembersMargin(20);
    
            ListGridField reportsTo = new ListGridField("ReportsTo") {
                {
                    final ComboBoxItem cbi = new ComboBoxItem() {
                        {
                            setOptionDataSource("employees");
                            ListGridField iD = new ListGridField("ReportsTo");
                            setPickListFields(iD);
                        }
                    };
                    setEditorProperties(cbi);
    
                    addChangedHandler(new ChangedHandler() {
                        @Override
                        public void onChanged(ChangedEvent event) {
                            final int row = event.getRowNum();
                            boundList.clearEditValue(row, "EmployeeId");
                        }
                    });
                }
            };
    
            ListGridField employeeId = new ListGridField("EmployeeId");
            ListGridField employeeStatus = new ListGridField("EmployeeStatus");
    
            boundList = new ListGrid();
            boundList.setFields(reportsTo, employeeId, employeeStatus);
            boundList.setHeight(200);
    
            boundList.setCanEdit(true);
    
            vStack.addMember(boundList);
    
            HLayout hLayout = new HLayout(10);
            hLayout.setMembersMargin(10);
            hLayout.setHeight(22);
    
            editBtn = new IButton("Edit");
            editBtn.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    boundList.startEditingNew();
                }
            });
            hLayout.addMember(editBtn);
            vStack.addMember(hLayout);
            vStack.draw();
        }
    
    }
    To reproduce, please start by clicking the Edit button. When the row appears, select a value from the dropdown in ReportsTo. Then You can see, that the row disappears immediately. When You remove the this line of code,

    Code:
     boundList.clearEditValue(row, "EmployeeId");
    it works as it should. I was thinking, that clearEditValue only removes the value from the specified ListGridField, in this case "EmployeeId". Can You please clarify if I misunderstand something?
    In Case You enter first some value in "EmployeeStatus" it works as expected.

    SmartClient Version: v12.0p_2019-01-25/PowerEdition Deployment (built 2019-01-25)


    Thanks in Advance,

    Kind Regards


    #2
    Hi Isomorphic,

    I have another issue with "clearEditValue" using setMask/setHint on a Field in an onChanged Event, please see this testcase:

    Code:
    package com.smartgwt.sample.client;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.core.KeyIdentifier;
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.util.Page;
    import com.smartgwt.client.util.PageKeyHandler;
    import com.smartgwt.client.util.SC;
    import com.smartgwt.client.widgets.IButton;
    import com.smartgwt.client.widgets.events.ClickEvent;
    import com.smartgwt.client.widgets.events.ClickHandler;
    import com.smartgwt.client.widgets.form.fields.ComboBoxItem;
    import com.smartgwt.client.widgets.form.fields.TextItem;
    import com.smartgwt.client.widgets.grid.ListGrid;
    import com.smartgwt.client.widgets.grid.ListGridField;
    import com.smartgwt.client.widgets.grid.events.ChangedEvent;
    import com.smartgwt.client.widgets.grid.events.ChangedHandler;
    import com.smartgwt.client.widgets.layout.HLayout;
    import com.smartgwt.client.widgets.layout.VStack;
    
    /**
     * Entry point classes define <code>onModuleLoad()</code>.
     */
    public class BuiltInDS implements EntryPoint {
        private ListGrid boundList;
        private IButton editBtn;
    
        /**
         * This is the entry point method.
         */
        public void onModuleLoad() {
            KeyIdentifier debugKey = new KeyIdentifier();
            debugKey.setCtrlKey(true);
            debugKey.setKeyName("D");
    
            Page.registerKey(debugKey, new PageKeyHandler() {
                public void execute(String keyName) {
                    SC.showConsole();
                }
            });
    
            VStack vStack = new VStack();
            vStack.setLeft(175);
            vStack.setTop(75);
            vStack.setWidth("70%");
            vStack.setMembersMargin(20);
    
            ListGridField employeeId = new ListGridField("EmployeeId");
            ListGridField employeeStatus = new ListGridField("EmployeeStatus");
            ListGridField employeeOrgUnit = new ListGridField("OrgUnit");
    
            boundList = new ListGrid();
            boundList.setDataSource(DataSource.get("employees"));
            ListGridField reportsTo = new ListGridField("ReportsTo") {
                {
                    final ComboBoxItem cbi = new ComboBoxItem() {
                        {
                            setOptionDataSource("employees");
                            ListGridField iD = new ListGridField("ReportsTo");
                            setPickListFields(iD);
                        }
                    };
                    setEditorProperties(cbi);
    
                    addChangedHandler(new ChangedHandler() {
                        @Override
                        public void onChanged(ChangedEvent event) {
                            final int row = event.getRowNum();
    
                            ((TextItem) event.getForm().getField("EmployeeStatus")).setMask("#####");
                            ((TextItem) event.getForm().getField("EmployeeStatus")).setHint("#####");
                            ((TextItem) event.getForm().getField("OrgUnit")).setMask("#####");
                            ((TextItem) event.getForm().getField("OrgUnit")).setHint("#####");
                            boundList.clearEditValue(row, "EmployeeStatus");
                            boundList.clearEditValue(row, "OrgUnit");
    
                        }
                    });
    
                }
            };
    
            boundList.setFields(employeeId, reportsTo, employeeStatus, employeeOrgUnit);
            boundList.setHeight(200);
    
            boundList.setCanEdit(true);
            boundList.setShowAllColumns(true);
            vStack.addMember(boundList);
    
            HLayout hLayout = new HLayout(10);
            hLayout.setMembersMargin(10);
            hLayout.setHeight(22);
    
            editBtn = new IButton("Edit");
            editBtn.addClickHandler(new ClickHandler() {
    
                public void onClick(ClickEvent event) {
                    boundList.startEditingNew();
                }
            });
            hLayout.addMember(editBtn);
            vStack.addMember(hLayout);
            vStack.draw();
        }
    
    }
    To reproduce, please follow these steps:

    1. Good-Case:

    1. Click "Edit"
    2. Add an Employee ID
    3. put something in Status
    4. put something in Org Unit
    3. Select a Manager
    4. Click out of the screen to safe

    now if You open the DeveloperConsole, you can see the add-requests data without the values EmployeeStatus and OrgUnit, the request only holds the values EmployeeId and ReportsTo. What is as I expected it because of clearEditValue in the onChanged-Handler.

    2. Issue-Case:

    1. Click "Edit"
    2. Add an Employee ID
    3. Select a Manager
    4. Click out of the screen to safe

    And here the issue happens. If You now look at the request in the DeveloperConsole, the add-request has those fields also in data: EmployeeStatus:"" OrgUnit:"" with values: ""

    I would have expected, that in 2. case, when one doesn't enter anything in EmployeeStatus or OrgUnit, those values would be passed as null and not as "". Is this behavior intended? We got problems with that on validation later, so would be good if null would be passed. Is this a framework related bug or do we have to change our logic on the validators?

    Thanks in Advance,

    Kind Regards

    Comment


      #3
      The first issue has been resolved in the 12.0 and 12.1 branch. Please try the next nightly build dated Jan 31 or above.
      We're looking at the second issue and will follow up when we have more information for you

      Regards
      Isomorphic Software

      Comment


        #4
        We've also made a change to address the second issue in the 12.0 and 12.1 branch. This will also be in the Jan 31 build.

        As an aside there are a couple of slightly odd things in the second test case which may be useful for you to be aware of
        - the "reportsTo" (AKA Manager) field is not initially visible as your code is written due to it being a detail field. The call to 'setShowAllColumns(true)' is probably an attempt to change that. That method is actually governing an unrelated piece of functionality (whether fields that are scrolled out of view will be rendered incrementally). The easiest way to change that is probably to add a little "showIfCondition" which explicitly returns true for the field.
        - the ComboBoxItem in the "reportsTo" field has a different field in the drop down pickList than what the user ends up picking. That's probably not what you were intending.
        You presumably want the user to pick the related "employeeId" value for the desired "manager".
        This happens automatically if you remove the explicit pickListFields definition, thanks to the foreignKey relationship defined in the dataSource, but if you wanted to explicitly specify a field to pick values from you could use the 'valueField' (and optionally the 'displayField') to govern this.

        Of course your sample code here was just a mock up so it's unlikely these issues are also present in your real usage but we thought some clarification around them might be useful to you anyway

        Regards
        Isomorphic Software

        Comment


          #5
          Hi Isomorphic,

          thank You for the clarification and of course, it was just a mock up to let You know what the problem was. The changes You applied are working very fine for us. Thanks again!

          Kind Regards

          Comment

          Working...
          X