Announcement

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

    Edit style

    Hi,

    I have a very simple listGrid:

    Code:
    public class TestingModule implements EntryPoint {
    
    	ListGrid lg = new ListGrid();
    
    	public void onModuleLoad() {
    
    		VLayout vlayout = new VLayout();
    		vlayout.setWidth100();
    		vlayout.setHeight100();
    		
    		final ListGrid lg = new ListGrid();
    
    		ListGridField name = new ListGridField("f_name", "Name");
    		lg.setFields(name);
    
    		IButton button = new IButton("Click me");
    		button.addClickHandler(new ClickHandler() {
    
    			@Override
    			public void onClick(ClickEvent event) {
    				lg.startEditingNew();
    			}
    		});
    		
    		lg.setDataSource(DataSource.get("table"));
    		lg.setWidth100();
    		lg.setHeight100();
    		
    		lg.setAutoSaveEdits(false);
    		
    		lg.fetchData();
    
    		vlayout.addMember(lg);
    		vlayout.addMember(button);
    		vlayout.draw();
    	}
    
    }
    The DataSource:
    Code:
    <DataSource ID="table" serverType="sql" tableName="t_schueler" 
    	 >
    
    	<fields>
    		<field name="f_schueler_id" type="sequence" primaryKey="true" />
    		<field name="f_name" type="text" required="true" />
    		
    	</fields>
    </DataSource>
    When I push the button, a new record may be edited (with lg.startEditingNew();).

    Please take a look at the attachment.
    The new record is "this is a new record". Note that the style is NOT blue, even if the record is still not saved in the database.
    To compare, I edited a cell: "edited record", and I don't understand why the "this is a new record" record is not blue, as it should be, since the record is pending to save.
    Is this a bug?

    I also get this error:
    Code:
    10:44:49.387 [ERROR] [zedes2V010214] 10:44:49.400:MDN0:WARN:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):getRange(5365, 5366): start beyond end of rows, returning empty list
    com.smartgwt.client.core.JsObject$SGWT_WARN: 10:44:49.400:MDN0:WARN:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):getRange(5365, 5366): start beyond end of rows, returning empty list
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
        at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:105)
        at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
        at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
        at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)
        at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
        at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
        at java.lang.Thread.run(Thread.java:745)

    Using smartGWT v9.1p_2014-09-06/PowerEdition Deployment (built 2014-09-06).

    Edit: I just saw The behaviour I described is during debug mode. When I compile, it works fine. But this should not be different, or ?
    Edit2: In another test cases, it is the other way around: during debug everything is ok, but when compiling the record is not shown blue, as it should be.
    So something is very strange here. I need the behavior to be consistent, so that unsaved edits are shown blue.
    Attached Files
    Last edited by edulid; 18 Sep 2014, 02:22.

    #2
    Thanks for the notification.

    We are reproducing the problem with the pending styling being broken in development mode, and are looking at how to address this. (This won't be visible to any actual users so shouldn't be a problem in any customer-facing deployments -- but we still consider it a bug and are looking into it).

    We are unable to reproduce this problem in compiled mode.
    If you find a way to reliably reproduce the problem in compiled mode, please let us know.

    We also see the warning about the ResultSet range. That should be safe to ignore but we'll take care of that as well

    Thanks
    Isomorphic Software

    Comment


      #3
      Originally posted by Isomorphic View Post
      Thanks for the notification.

      We are unable to reproduce this problem in compiled mode.
      If you find a way to reliably reproduce the problem in compiled mode, please let us know.
      EntryPoint:
      Code:
      public class TestingModule implements EntryPoint {
      
      	ListGrid lg = new ListGrid();
      
      	public void onModuleLoad() {
      
      		VLayout vlayout = new VLayout();
      
      		IButton button = new IButton("Click me");
      		button.addClickHandler(new ClickHandler() {
      
      			@Override
      			public void onClick(ClickEvent event) {
      				MyWindow2 w = new MyWindow2(); 
      				w.show();
      			}
      		});
      		vlayout.addMember(button);
      		vlayout.draw();
      	}
      
      }
      MyWindow2:
      Code:
      public class MyWindow2 extends Window {
      
      	private final ListGrid lg;
      
      	private final IButton newButton;
      
      	public MyWindow2() {
      		setWidth(1050);
      		setHeight(760);
      		setAutoCenter(true);
      		setIsModal(true);
      		setShowModalMask(true);
      		setShowMaximizeButton(true);
      
      		VLayout vlayout = new VLayout(12);
      		vlayout.setPadding(25);
      
      		ListGridField idField = new ListGridField("f_id");
      		idField.setHidden(true);
      
      		ListGridField inventarnummerField = new ListGridField("f_name", "Name");
      		inventarnummerField.setRequired(true);
      
      		lg = new ListGrid() {
      			@Override
      			protected String getCellCSSText(ListGridRecord record, int rowNum,
      					int colNum) {
      				return null;
      			}
      
      		};
      		lg.setDataSource(DataSource.get("table"));
      
      		lg.setCanEdit(true);
      		lg.setEditEvent(ListGridEditEvent.DOUBLECLICK);
      		lg.setEditByCell(false);
      		lg.setModalEditing(true);
      		lg.setAutoSaveEdits(false);
      		lg.setConfirmDiscardEdits(false);
      		lg.setListEndEditAction(RowEndEditAction.DONE);
      		lg.setSelectionType(SelectionStyle.SIMPLE);
      		lg.setSelectionAppearance(SelectionAppearance.CHECKBOX);
      
      		lg.addEditorEnterHandler(new EditorEnterHandler() {
      
      			@Override
      			public void onEditorEnter(EditorEnterEvent event) {
      				if (event.getRecord() != null) {
      					lg.deselectRecord(event.getRecord());
      				}
      			}
      		});
      		lg.setWidth("100%");
      
      		lg.setAutoFetchData(false);
      		lg.setFields(idField, inventarnummerField);
      
      		/*
      		 * Buttons.
      		 */
      		HLayout buttonsLayout = new HLayout(15);
      		buttonsLayout.setHeight(25);
      		buttonsLayout.setAlign(Alignment.LEFT);
      
      		newButton = new IButton("New record");
      		newButton.setIcon(Zedes2Icons.NEW.getFilename());
      		newButton.setWidth(190);
      		newButton.addClickHandler(new ClickHandler() {
      			@Override
      			public void onClick(ClickEvent event) {
      				onNewExemplarButtonClick();
      			}
      		});
      
      		buttonsLayout.addMember(newButton);
      
      		vlayout.addMember(lg);
      		vlayout.addMember(buttonsLayout);
      
      		addItem(vlayout);
      
      	}
      
      	private void onNewExemplarButtonClick() {
      		lg.startEditingNew();
      
      	}
      
      }
      Just push "New record", then you will see that the pending records are *not* blue.

      I think the problem is with:
      Code:
      lg = new ListGrid() {
      			@Override
      			protected String getCellCSSText(ListGridRecord record, int rowNum,
      					int colNum) {
      				return null;
      			}
      
      		};
      I need this because I need to style some cells differently. The original code is something like:
      Code:
      lg = new ListGrid() {
      			@Override
      			protected String getCellCSSText(ListGridRecord record, int rowNum,
      					int colNum) {
                                      if (...) "font-style:italic;color:#808080"; else return null;
      			}
      
      		};
      I tried with return ""; instead of return null, but same problem...

      Comment


        #4
        We haven't tried your test case, but this would appear to be expected - the problem is that getCellCSSText is expected to provide the css text for the cell - it's a way to override and customize what css text is applied.
        In this case it's failing to pick up the edit-pending css text so it's not being applied.
        Calling "super" should do the trick, or returning the edit-pending-cssText directly in your code - or using an editPendingBaseStyle instead of cssText.

        Regards
        Isomorphic Software

        Comment


          #5
          Originally posted by Isomorphic View Post
          We haven't tried your test case, but this would appear to be expected - the problem is that getCellCSSText is expected to provide the css text for the cell - it's a way to override and customize what css text is applied.
          In this case it's failing to pick up the edit-pending css text so it's not being applied.
          Calling "super" should do the trick, or returning the edit-pending-cssText directly in your code - or using an editPendingBaseStyle instead of cssText.
          Calling super.getCellCSSText(record, rowNum, colNum); did not work:

          Code:
          lg = new ListGrid() {
          			@Override
          			protected String getCellCSSText(ListGridRecord record, int rowNum,
          					int colNum) {
          				return super.getCellCSSText(record, rowNum, colNum);
          			}
          			
          		};
          I am not sure how the other approaches are supposed to work:
          Calling lg.setEditPendingCSSText("color:#0066CC;"); did not work either, since that should already be the default.
          Using an editPendingBaseStyle instead of cssText? I am trying to change the style of the non-pending rows, and have the default blue-style of the pending rows. So how should this work?
          super.getCellCSSText(record, rowNum, colNum); does not work either.

          The only thing I think may work would be something like this:
          Code:
          lg = new ListGrid() {
          			@Override
          			protected String getCellCSSText(ListGridRecord record, int rowNum,
          					int colNum) {
                                          //is this a pending row?
                                          int[] pendingRows = getAllEditRows();
                                          if (rowNum in pendingRows) return getEditPendingCSSText();
                                          else return null;
          			}
          			
          		};
          But I think this would be only a workaround to a bug, since either "return null", nor "return """, nor "return super.getCellCSSText(record, rowNum, colNum);" works.
          Last edited by edulid; 23 Sep 2014, 10:07.

          Comment


            #6
            Hmm - not sure why calling super didn't work. We will look into that.
            I was suggesting that as an alternative approach you call, and return the result of 'getEditPendingCSSText()' within your getCellCSSText override if you're in a cell with changes - so as to return the default pending style.

            Or, alternatively to set up your grid at init time such that the editPendingCSSText is null, and the pending style is achieved via a custom css styleName (at which point the fact that your getCellCSSText override doesn't return any 'pending style' css text would be moot).

            Regards
            Isomorphic Software

            Comment


              #7
              Originally posted by Isomorphic View Post
              Hmm - not sure why calling super didn't work. We will look into that.
              I was suggesting that as an alternative approach you call, and return the result of 'getEditPendingCSSText()' within your getCellCSSText override if you're in a cell with changes - so as to return the default pending style.
              Yes, we had a crossposting,.. please check my last edit... but I still think this would be a workaround for a bug.
              Your second solution
              Or, alternatively to set up your grid at init time such that the editPendingCSSText is null, and the pending style is achieved via a custom css styleName (at which point the fact that your getCellCSSText override doesn't return any 'pending style' css text would be moot)
              also seems as a workaround ..

              Comment


                #8
                I solved the issue with this workaround:
                Code:
                lg = new ListGrid() {
                			@Override
                			protected String getCellCSSText(ListGridRecord record, int rowNum,
                					int colNum) {
                				int[] editRows = getAllEditRows();
                				for (int i=0; i<= editRows.length-1; i++) {
                					if (editRows[i] == rowNum) {
                						return getEditPendingCSSText();
                					}
                				}
                				return super.getCellCSSText(record, rowNum, colNum);
                			}
                			
                		};
                Nevertheless, please let me know if the super.getCellCSSText(record, rowNum, colNum) has a bug and if it gets fixed:

                Code:
                lg = new ListGrid() {
                			@Override
                			protected String getCellCSSText(ListGridRecord record, int rowNum,
                					int colNum) {
                				return super.getCellCSSText(record, rowNum, colNum);
                			}
                			
                		};

                Comment


                  #9
                  Great that you solved it. Note there are also "rowHasChanges" /"cellHasChanges" (methods on the grid to avoid the for-loop you've added).

                  The issue with "super" is assigned to a developer for investigation

                  Regards
                  Isomorphic Software

                  Comment


                    #10
                    Thank you! I didn't know the "rowHasChanges" method, since i was looking for the word "pending" in the docs.

                    Comment


                      #11
                      Originally posted by edulid View Post
                      I solved the issue with this workaround:
                      Nevertheless, please let me know if the super.getCellCSSText(record, rowNum, colNum) has a bug and if it gets fixed:

                      Code:
                      lg = new ListGrid() {
                      			@Override
                      			protected String getCellCSSText(ListGridRecord record, int rowNum,
                      					int colNum) {
                      				return super.getCellCSSText(record, rowNum, colNum);
                      			}
                      			
                      		};
                      We're not sure what the claimed problem is with the above override. As shown where it's just calling super it will be as if the function were not overriden at all. We tested this in the exact version you mentioned, and we're seeing the expected blue styling for the name once it's edited.

                      What makes you think it's not working?

                      Comment


                        #12
                        Originally posted by Isomorphic View Post

                        What makes you think it's not working?
                        That I don't see the blue styling when edited... I will test this again and let you know.

                        Comment


                          #13
                          We verified it working agains SWGT v9.1p 2014-09-06, using your source code. The only change was to comment out

                          Code:
                          newButton.setIcon(Zedes2Icons.NEW.getFilename());
                          since you didn't provide that class.

                          Comment

                          Working...
                          X