Results 1 to 2 of 2

Thread: ListStoreEditor doesn't flush changes to edited model

  1. #1
    Sencha User
    Join Date
    Jun 2011
    Posts
    14

    Default ListStoreEditor doesn't flush changes to edited model

    I have the GridEditor editor (code below) to edit lists in model.
    RecipeEditor is a widget class initializes with Editor & RequestFactory, also implements Editor<> initerface.

    Everything works ok, except that ListStore editor flushes, but doesn't commit changes into edited model (as it is not LeafValueEditor).

    Traced this behavior to Flusher.class to GWT 2.6.1:
    Code:
        LeafValueEditor<Q> asLeaf = ctx.asLeafValueEditor();    if (delegate.shouldFlush() && asLeaf != null && ctx.canSetInModel()) {
          ctx.setInModel(asLeaf.getValue());
    So the question is how to transfer commited data to model list?


    Code:
    public class RecipeEditor extends BaseEditor<RecipeProxy> {
    
        interface RecipeEditorDriver extends RequestFactoryEditorDriver<RecipeProxy, RecipeEditor> {
        }
    
    
        private RecipeRequestContext requestContext;
        private RecipeProxy model;
    
    
        @Path("name")
        TextField name;
    
    
        TextField title;
        TextField annotation;
        TextArea content;
        CheckBox published;
    
    
        @Ignore
        TextButton selectGoods;
    
    
        GridEditor<GoodsProxy> goods;
    
    ...
    Code:
    public class GridEditor<T extends BaseEntityProxy> extends Composite implements IsEditor<Editor<List<T>>> {
    
        protected ListStore<T> listStore;
        protected GridEditing<T> editing;
        private ListStoreEditor<T> editor;
    
    
        public class EmptyValueProvider<T> implements ValueProvider<T, String> {
    
    
            @Override
            public String getValue(T object) {
                return "";  //To change body of implemented methods use File | Settings | File Templates.
            }
    
    
            @Override
            public void setValue(T object, String value) {
                //To change body of implemented methods use File | Settings | File Templates.
            }
    
    
            @Override
            public String getPath() {
                return "";  //To change body of implemented methods use File | Settings | File Templates.
            }
        }
    
    
        public GridEditor(BaseProxyProperties<T> properties, List<ColumnConfig<T, ?>> columns) {
            this(properties, columns, null);
        }
    
    
        public GridEditor(BaseProxyProperties<T> properties, List<ColumnConfig<T, ?>> columns, List<IsField> editors) {
    
    
            listStore = new ListStore<>(properties.stableId());
            editor = new ListStoreEditor<>(listStore);
    
    
            for (ColumnConfig<T, ?> column : columns) {
                if (column.getCell() instanceof AnchorCell) {
                    ((AnchorCell<T>) column.getCell()).setListStore(listStore);
                }
            }
    
    
            ColumnConfig<T, String> colActions = new ColumnConfig<>(new EmptyValueProvider<>(), 50, AppBundle.MESSAGES.label_remove());
            ButtonCell<String> remove = new ButtonCell<>();
            remove.setText("");
            remove.setIcon(AppBundle.IMAGES.cancel());
            remove.addSelectHandler(new SelectEvent.SelectHandler() {
                @Override
                public void onSelect(SelectEvent event) {
                    listStore.remove(event.getContext().getIndex());
                    //T proxy = listStore.get(event.getContext().getIndex());
                }
            });
            colActions.setCell(remove);
            columns.add(colActions);
    
    
            ColumnModel<T> cm = new ColumnModel<>(columns);
    
    
            Grid<T> grid = new Grid<>(listStore, cm);
            grid.setPixelSize(500, 200);
    
    
            editing = new GridInlineEditing<>(grid);
            if (editors != null) {
                for (IsField editor : editors) {
                    if (editor != null) {
                        editing.addEditor(columns.get(editors.indexOf(editor)), editor);
                    }
                }
            }
    
    
            if (getBeforeStartEditHandler() != null)
                editing.addBeforeStartEditHandler(getBeforeStartEditHandler());
    
    
            initWidget(grid);
    
    
            //grid.getView().setAutoExpandColumn(colValue);
        }
    
    
        public BeforeStartEditEvent.BeforeStartEditHandler<T> getBeforeStartEditHandler() {
            return null;
        }
    
    
        public void addCompleteEditHandler(CompleteEditEvent.CompleteEditHandler<T> handler) {
            editing.addCompleteEditHandler(handler);
        }
    
    
        public void startEdit(T value) {
            listStore.add(value);
            editing.startEditing(new Grid.GridCell(listStore.size(), 0));
        }
    
    
        public void add(T entity) {
            listStore.add(entity);
        }
    
    
        public List<T> getValue() {
            return listStore.getAll();
        }
    
    
        public void cancelEdit() {
            editing.cancelEditing();
        }
    
    
        @Override
        public Editor<List<T>> asEditor() {
            return editor;
        }
    
    
        public void setValue(List<T> newList) {
            listStore.clear();
            listStore.addAll(newList);
        }
    }

  2. #2
    Sencha User
    Join Date
    Jan 2014
    Posts
    3

    Default

    Hi,

    I have the same problem. Have you found a solution? I am using GXT 3.1.4 and GWT 2.7.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •