Announcement

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

    ListGrid datasource allows adding multiple rows with the same primarykey value

    Hello,

    I have a ListGrid with 2 fields Area and Name. I have set Area as primaryKey. When adding 2 rows with the same Area value, I get no error although the values should be unique. Also, if i modify the Name of the 2nd row, the 1st row's Name is the one being edited.

    I am using SmartGwt v3.0

    Here is a sample code:
    Code:
    public void onModuleLoad() {
        VLayout canvas = new VLayout();
        canvas.setWidth(300);
        canvas.setLeft(20);
        canvas.setHeight(500);
    
        final ListGrid listGrid = new ListGrid();
        listGrid.setAlternateRecordStyles(true);
        listGrid.setEmptyMessage("Empty list!");
        listGrid.setAutoFetchData(true);
        
        DataSourceIntegerField areaField = new DataSourceIntegerField("area", "Area");
        DataSourceTextField nameField = new DataSourceTextField("name", "Name");
        areaField.setPrimaryKey(true);
        
        DataSource dataSource = new DataSource();
        dataSource.setClientOnly(true);
        dataSource.setFields(areaField, nameField);
        listGrid.setDataSource(dataSource);
        
        IButton addDataButton = new IButton("Add Data");
        addDataButton.setLeft(0);
        addDataButton.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                listGrid.startEditingNew();
            }
        });
        
        canvas.addMember(addDataButton);
        canvas.addMember(listGrid);
        
        canvas.draw();
    }
Working...
X