Announcement

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

    ListGrid with ClientOnly DataSource problem

    SmartGWT 3.1 LGPL

    Hi guys,

    I have a problem with a ListGrid backed by a ClientOnly datasource.

    Below you can find the simplest code that you need to reproduce the problem (sorry, my company forbids uploading files).

    Scenario #1:
    1. Open the page.
    2. Click on the "Add" button.
    3. Enter some value.
    4. Click on the "Save" button (while focus is still in the listgrid cell with the entered data).

    In the handler we inspect the datasource data and see no records.

    If you can see in the commented code, I did try to use saveAllEdits method, but in this case we get a duplicate in the datasource (you can try it by uncommenting several lines for Test#2 in the code).

    How can I get the correct records? I expect only one saved record that I entered.


    Code:
    import com.google.gwt.core.client.EntryPoint;
    import com.google.gwt.user.client.Window;
    import com.smartgwt.client.core.Function;
    import com.smartgwt.client.data.*;
    import com.smartgwt.client.widgets.IButton;
    import com.smartgwt.client.widgets.events.ClickEvent;
    import com.smartgwt.client.widgets.events.ClickHandler;
    import com.smartgwt.client.widgets.grid.ListGrid;
    import com.smartgwt.client.widgets.layout.VLayout;
    
    import static com.smartgwt.client.types.FieldType.SEQUENCE;
    import static com.smartgwt.client.types.FieldType.TEXT;
    
    public class TestGridEntryPoint implements EntryPoint {
    
        @Override
        public void onModuleLoad() {
            VLayout vLayout = new VLayout();
    
            final ListGrid listGrid = new ListGrid();
            listGrid.setWidth(100);
            listGrid.setHeight(100);
            listGrid.setAutoSaveEdits(true);
            listGrid.setDataSource(new TestDataSource());
    
            vLayout.addMember(listGrid);
    
            IButton addRecordButton = new IButton("Add");
            addRecordButton.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    listGrid.startEditingNew();
                }
            });
            vLayout.addMember(addRecordButton);
    
            IButton saveButton = new IButton("Save");
            saveButton.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
    //              Test #1: we get 0 records
    //
                    Record[] records = listGrid.getDataSource().getCacheData();
                    Window.alert(String.valueOf(records.length));
    
    //              Test #2: we get 2 records (duplicate)
    //                listGrid.saveAllEdits(new Function() {
    //                    @Override
    //                    public void execute() {
    //                        Record[] records = listGrid.getDataSource().getCacheData();
    //                        Window.alert(String.valueOf(records.length));
    //                    }
    //                });
                }
            });
            vLayout.addMember(saveButton);
    
            vLayout.draw();
        }
    
        public static class TestDataSource extends DataSource {
    
            public TestDataSource() {
                DataSourceField idField = new DataSourceField("id", SEQUENCE);
                idField.setPrimaryKey(true);
                idField.setHidden(true);
    
                DataSourceField nameField = new DataSourceField("name", TEXT);
    
                setFields(idField, nameField);
    
                setClientOnly(true);
            }
    
            @Override
            protected DSResponse getClientOnlyResponse(DSRequest request, Record[] serverData) {
                return super.getClientOnlyResponse(request, serverData);    //To change body of overridden methods use File | Settings | File Templates.
            }
        }
    }
    Last edited by serge_hid; 24 Feb 2014, 02:22.

    #2
    Guys,

    Any update on this issue?

    Right now it seems that my post is completely ignored. Any response (like "it is a bug and there is no workaround" or "it is not a bug" or "we are looking into this") is more than welcome.

    Thank you.

    Comment


      #3
      SmartGWT 3.1 is pretty old. In such cases Isomorphic always appreciates exact browser and version details.
      For example, 3.1 might not work at all with IE10/IE11.

      Best regards,
      Blama

      Comment


        #4
        Thanks Blama.

        The issue seems to be reproducible in IE 8. Everything works fine in Chrome 33 and Firefox 27.

        Comment


          #5
          Still missing the exact SmartGWT 3.1 version.

          Comment


            #6
            Sorry, I thought the browser version was meant.

            SmartClient Version: v8.3_2012-11-20/LGPL Development Only (built 2012-11-20)
            GWT version: 2.5
            Last edited by serge_hid; 25 Feb 2014, 08:36.

            Comment


              #7
              Hi serge_hid,

              please see http://www.smartclient.com/product/d...erReleases.jsp.
              v8.3_2012-11-20/LGPL Development Only (built 2012-11-20) is the 1st release of 3.1.

              If you can't switch to 4.0p (or 4.1d, as Isomorphic suggests right now), at least use the latest patched build (Original release (11/20/2012). Please use latest patched versions above to avoid hitting already-fixed bugs.).

              Best regards,
              Blama

              Comment

              Working...
              X