Announcement

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

    ListGrid canEdit:false is lost after startEditingNew

    Hi Isomorphic,

    please see this BuiltInDS based testcase (v10.0p_2015-10-23).

    BuiltInDS.java:
    Code:
    package com.smartgwt.sample.client;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.core.KeyIdentifier;
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.util.Page;
    import com.smartgwt.client.util.PageKeyHandler;
    import com.smartgwt.client.util.SC;
    import com.smartgwt.client.widgets.IButton;
    import com.smartgwt.client.widgets.Window;
    import com.smartgwt.client.widgets.events.ClickEvent;
    import com.smartgwt.client.widgets.events.ClickHandler;
    import com.smartgwt.client.widgets.events.DoubleClickEvent;
    import com.smartgwt.client.widgets.events.DoubleClickHandler;
    import com.smartgwt.client.widgets.grid.ListGrid;
    import com.smartgwt.client.widgets.layout.VLayout;
    
    public class BuiltInDS implements EntryPoint {
        private VLayout mainLayout;
        private IButton recreateBtn;
        private IButton startEditNewBtn;
        private ListGrid lg;
    
        public void onModuleLoad() {
            KeyIdentifier debugKey = new KeyIdentifier();
            debugKey.setCtrlKey(true);
            debugKey.setKeyName("D");
    
            Page.registerKey(debugKey, new PageKeyHandler() {
                public void execute(String keyName) {
                    SC.showConsole();
                }
            });
    
            mainLayout = new VLayout(20);
            mainLayout.setWidth100();
            mainLayout.setHeight100();
    
            recreateBtn = new IButton("Recreate");
            recreateBtn.setWidth(150);
            recreateBtn.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    recreate();
                }
            });
            mainLayout.addMember(recreateBtn);
    
            startEditNewBtn = new IButton("Start editing new");
            startEditNewBtn.setWidth(150);
            startEditNewBtn.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    lg.startEditingNew();
                }
            });
            mainLayout.addMember(startEditNewBtn);
    
            recreate();
            mainLayout.draw();
        }
    
        private void recreate() {
            if (lg != null) {
                mainLayout.removeMember(lg);
                lg.markForDestroy();
            }
    
            lg = new ListGrid(DataSource.get("animals"));
            lg.setWidth("90%");
            lg.setHeight("80%");
            lg.setAutoFetchData(false);
            lg.setCanEdit(true);
            lg.setCanEdit(false);
            lg.addDoubleClickHandler(new DoubleClickHandler() {
                @Override
                public void onDoubleClick(DoubleClickEvent event) {
                    Window w = new Window() {
                        {
                            setPadding(0);
                            setMargin(0);
                            setMembersMargin(0);
                            setModalMaskOpacity(60);
                            setWidth(700);
                            setHeight(700);
                            setPadding(100);
                            setTitle("Testwindow, see ListGrid row below");
                            setShowMinimizeButton(false);
                            setIsModal(true);
                            setShowModalMask(true);
                            setShowHeaderIcon(true);
                            centerInPage();
                        }
                    };
                    w.show();
                }
            });
            mainLayout.addMember(lg);
            lg.fetchData();
        }
    }
    • Doubleclick the ListGrid in order to see that a window opens and the edit-mode is not started.
    • Click the startEditingNew-button
    • Complete a new row
    • Doubleclick the ListGrid in order to see that a window opens and the edit-mode opens in the background

    In my opinion, using startEditingNew should not enable the edit mode permanently.
    In my application, I do the "easy" masterdata with startEditingNew and then details in a tabbed window shown on doubleclick.

    Best regards
    Blama

    #2
    A grid must be editable (canEdit:true) for it to be edited, so when startEditing() / startEditingNew() are called programmatically we automatically enable this flag if it was not previously enabled.

    It sounds like what you're after is canEdit:true but the listGrid editEvent being set to "none", so editing won't begin on a double-click - just when you programmatically tell it to.

    Regards
    Isomorphic Software

    Comment


      #3
      Hi Isomorphic,

      this sounds like the setting I'm looking for, thank you.

      Best regards
      Blama

      Comment


        #4
        Hi Isomorphic,

        I tested it and it is the functionality I was looking for. Thanks again.

        Best regards
        Blama

        Comment

        Working...
        X