Removing old record after edit
Asked Answered
V

1

7

So currently, when I edit a record off a panel that extends VLayout, double click the field, change the texts, and press enter to save my edit. The newly edited record appears as a standalone record, while the one I just edited is still there.

Is there a way to remove the old record?

myForm.getDataSource().updateData(currentRecord, new DSCallback()
                        {
                            @Override
                            public void execute(DSResponse response, Object rawData, DSRequest request)
                            {
                                window.hide();
                            }
                        });
Vidrine answered 4/8, 2014 at 19:43 Comment(2)
Is your record bean implementing the equals() method?Seng
Please share some piece of code for fast response.Elijah
I
0

SmartGwt doesn't support a customized behavior for this operation. You should program it by yourself.

Just create a new ListGridField and refresh your second grid in the CallBack after the remove operation. Your first approach could be the following:

ListGridField removeListGridField = new ListGridField("removeButton", 20);

removeListGridField.setType(ListGridFieldType.ICON);
removeListGridField.setCellIcon("[SKIN]actions/remove.png");
removeListGridField.setCanEdit(false);
removeListGridField.setCanFilter(false);
removeListGridField.setCanGroupBy(false);
removeListGridField.setCanSort(false);
removeListGridField.setCanDragResize(false);
removeListGridField.setCanFreeze(false);
removeListGridField.setCanHide(false);

removeListGridField.addRecordClickHandler(new RecordClickHandler()
{
    @Override
    public void onRecordClick(RecordClickEvent event)
    {
        if (event.getRecord() == null) // local record
        {
            discardEdits(event.getRecordNum(), 0);
            yourGrid.fetchData();
        }
        else
            removeData(event.getRecord(), new DSCallback()
        {
        @Override

    public void execute(DSResponse dsResponse, Object data, DSRequest dsRequest)
    {
        yourGrid.fetchData();
    }
    });
}
});

See this code can helps you.

Intuitivism answered 6/8, 2015 at 9:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.