Announcement

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

    ListGrid duplicates existing records when adding a new Record - SmartGWT 4.1p only

    I'm using smartgwt power edition and have encountered a situation where a ListGrid will duplicate the existing records in the ListGrid when adding a new record.

    This issue does not happen in version
    SmartClient*Version:*v9.0p_2014-07-12/PowerEdition Deployment*(built*2014-07-12)

    but it does happen in versions
    SmartClient Version: v9.1p_2014-07-15/PowerEdition Deployment (built 2014-07-15)
    SmartClient Version: v9.1p_2014-03-09/PowerEdition Deployment (built 2014-03-09)


    I have distilled our code down to a simple example. We are loading a ListGrid with items belonging to a specific assortment. The initial criteria contains the assortment_id. When a record is added to the ListGrid (or if added to the DataSource attached to the ListGrid), the correct SQL insert occurs. The response to the addData() request is filled with a query against the items table that does not filter the result down to the new item, so it returns all items from the table. The 4.0p version generates the correct query with the item id filter in the Where clause. Both logs are attached.

    The ListGrid is populated with the new item, and it also gets a copy of all the items that were already in the ListGrid. The database still contains the correct records, as this duplication only happens on the ListGrid.

    Here is the Layout class used to reproduce the issue

    Code:
    public class TestLayout extends VLayout {
        private Record strategy;
        private Record assortment;
        private ListGrid itemsGrid;
    
        public TestLayout(Record strategy, Record assortment) {
            setMembersMargin(10);
    
            this.strategy = strategy;
            this.assortment = assortment;
    
            this.itemsGrid = createItemsGrid();
            addMember(itemsGrid);
            addMember(createButtons());
        }
    
        private ListGrid createItemsGrid() {
    
            final DataSource assortmentItemDS = DataSource.get("testassortmentItemDS");
    
            final ListGrid grid = new ListGrid();
            grid.setWidth100();
            grid.setHeight(500);
            grid.setDataSource(assortmentItemDS);
            grid.setInitialCriteria(getInitialCriteria());
            grid.setCriteria(getInitialCriteria());
            grid.setAutoFetchData(true);
    
            return grid;
        }
    
        private Layout createButtons() {
            HLayout layout = new HLayout(10);
            IButton addItemButton = new IButton("Add Item");
            addItemButton.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
    
                    Record newRecord = new Record();
                    newRecord.setAttribute("assortment_id", 55873);
                    newRecord.setAttribute("q_itm_id", "541");
                    newRecord.setAttribute("rptStatus", "L");
                    newRecord.setAttribute("name", "test");
                    newRecord.setAttribute("planName", "test");
                    newRecord.setAttribute("repeat", Boolean.TRUE);
    
                    itemsGrid.addData(newRecord);
                }
            });
            layout.addMember(addItemButton);
            return layout;
        }
    
        private Criteria getInitialCriteria() {
            Criteria shoppingListCriteria = new Criteria();
            shoppingListCriteria.addCriteria("assortment_id", this.assortment.getAttributeAsInt("id"));
            return shoppingListCriteria;
        }
    
    }
    Attached Files
Working...
X