开发者

ListGrid Duplicates created after adding records onload then dragging the same again

开发者 https://www.devze.com 2023-03-10 07:46 出处:网络
I have a View where I have Drag and Drop working between 2 ListGrid-s, and after dragging a few records I then save them to a POJO type object upon clicking a button \"Save\".

I have a View where I have Drag and Drop working between 2 ListGrid-s, and after dragging a few records I then save them to a POJO type object upon clicking a button "Save".

When I'm accessing again that view it calls a method loadGrid that pulls those values from the POJO and adds them back into the ListGrid that they were dragged to earlier, so they can see what they already have added previously, however when I drag and drop again it lets me add the same primary keys creating duplicates records in the ListGrid.

How can I make it so that it sees these records as the same? The primary key is the same, the types are the same, not sure what it could be...

I'm using transferSelectedData to add the new privileges to the assigned list grid and setPreventDuplicates(true).

ListGrid avPrivGrid = null;
 ListGrid assPriv = null;
 TransferImgButton but = null;

 avPrivGrid = new ListGrid();
 PrivilegesDataSource privDataSource = new PrivilegesDataSource();
 avPrivGrid.setDataSource(privDataSource);
 avPrivGrid.setAutoFetchData(false);

 ListGridField propUsername = new ListGridField("privName", "Available Priv");
 propUsername.setType(ListGridFieldType.TEXT);
 avPrivGrid.setFields(propUsername);

 assPriv = new ListGrid();
 assPriv.setCanAcceptDroppedRecords(true);
 assPriv.setCanEdit(false); 
 assPriv.setAutoFetchData(false);
 assPriv.setPreventDuplicates(true);
 assPriv.setDuplicateDragMessage("Can not add duplicates!");
 assPriv.setCanSelectAll(false);
 assPriv.setAlternateRecordStyles(true);
 assPriv.setLeaveScrollbarGap(true);
 assPriv.setMinHeight(100);

 ListGridField propUserN = new ListGridField("privName", "Assigned Priv");
 propUserN.setWidth("30%");
 propUserN.setType(ListGridFieldType.TEXT);
 ListGridField propId = new ListGridField("privId");
 propId.setWidth("30%");
 propId.setType(ListGridFieldType.TEXT);
 propId.setHidden(true);
 assPriv.setFields(propId, propUserN);

 but = new TransferImgButton(TransferImgButton.RIGHT);
  but.addClic开发者_C百科kHandler(new ClickHandler()
 {
    public void onClick(ClickEvent event)
    {
        //Duplicate checking will happen automagially!
            assPriv.transferSelectedData(avPrivGrid);
    }
 });
 avPrivGrid.fetchData();


Check if the ID field set as the primary key in the Datasource.

[IdField].setPrimaryKey(true);


I have the same problem and I have [IdField].setPrimaryKey(true); Up to here, my conclusion is that whenever there is a databound list of records, the setDragDataAction(DragDataAction.MOVE) is not working. If it's not databound, it works.

0

精彩评论

暂无评论...
验证码 换一张
取 消