Announcement

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

    ListGrid.refreshCell(): first parameter rowNum not present, returning

    I have an editable ListGrid where I have setData() to a Record array. When I edit a cell in a row of the grid and then tab out of that cell I get a series of error messages in the console. Does this indicate a problem? Everything seems to work other than the error message showing up.
    Code:
    22:10:17.865 [ERROR] [ipgui] 22:10:17.864:WARN:ListGrid:isc_PoItemAssortment1DLayout$2_0:ListGrid.refreshCell(): first parameter rowNum not present, returning
    com.smartgwt.client.core.JsObject$SGWT_WARN: 22:10:17.864:WARN:ListGrid:isc_PoItemAssortment1DLayout$2_0:ListGrid.refreshCell(): first parameter rowNum not present, returning
        at sun.reflect.GeneratedConstructorAccessor229.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        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:157)
        at com.google.gwt.dev.shell.BrowserChannel.reactToMessages(BrowserChannel.java:1668)
        at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:401)
        at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222)
        at java.lang.Thread.run(Thread.java:637)

    #2
    Do you in fact have a call to refreshCell() where the rowNum is not passed?

    If not, is this error reproducible in a sample?

    Comment


      #3
      The error is being thrown when my CellSavedHandler executes. It runs a calculation on other fields in the record being edited and updates another field in the same record. Here is the code. Is there something wrong with this approach? My original attempt was to just use setAttribute() to update the calculated field EXTENDED_TOTAL (which is itself editable), but that didn't change the value shown in the grid. This approach seems to work except for the error messages.
      Code:
      field.addCellSavedHandler(new CellSavedHandler() {
      	@Override
      	public void onCellSaved(CellSavedEvent event) {
      		Record rec = grid.getRecord(event.getRowNum());
      		rec.setAttribute(PER_STORE, getPerStoreTotal(rec));
      		grid.startEditing(event.getRowNum(), grid.getFieldNum(EXTENDED_TOTAL), true);
      		grid.setEditValue(event.getRowNum(), grid.getFieldNum(EXTENDED_TOTAL), 
      				getPerStoreTotal(rec) * rec.getAttributeAsInt(NUMBER_OF_STORES));
      		grid.endEditing();
      	}				
      });
      The getPerStoreTotal(rec) method just iterates over selected fields in the record and sums them up (using record.getAttribute() to get the value).

      Comment


        #4
        The only thing that could crash in that method is that getRecord() will return null for a newly added record - use getEditedRecord() instead.

        Most likely the crash is in getPerStoreTotal(). Do you know what's actually crashing?

        Comment


          #5
          It is the call to endEditing() that throws the error. Removing that stopped the error reporting and I realize I don't really want to be calling that anyway.

          I'll switch to using getEditedRecord() as you suggest, but I have one question. The javadocs say "The returned value is never null, and can be freely modified." Does that mean calling getEditedRecord().setAttribute() is the right way to update fields in that record so they are reflected in the grid, or should I still use grid.startEditing() and setEditValue()?

          Comment


            #6
            getEditedRecord() is basically returning you a copy of getRecord() as combined with getEditValues(), so no, setAttribute() would not have an effect.

            As with editing in general, getRecord().setAttribute() affects the record directly (if there is one) and is tantamount to telling the grid that the server-side, stored data has been changed. Then, setEditValue() is the equivalent of the user haven't changed the value.

            Comment


              #7
              Got it. Thanks.

              Comment


                #8
                I'm still getting the ListGrid.refreshCell() error, only now it is only after editing a row and tabbing out to another row, which I suppose is generating a call to endEditing() which was where I was originally triggering the error. I also have setSaveByCell(true) on the grid in case that makes a difference.

                I also have a question about getEditedRecord() and setEditValue(). It seems to generate a javascript level error if the field is not visible (if the user hides that column via the column chooser). So I've create this helper method to set the value one way or another depending on the column visibility. Should this be necessary?
                Code:
                private void setEditValueOrAttribute(int rowNum, String fieldName, Integer newValue) {
                	if (grid.fieldIsVisible(fieldName)) {
                		grid.setEditValue(rowNum, fieldName, newValue);
                	}
                	else
                		grid.getRecord(rowNum).setAttribute(fieldName, newValue);
                }

                Comment


                  #9
                  Hi Jay
                  On the JS error - no you should be able to call setEditValue(...) and pass in the fieldName for a non visible field.

                  I tested this out by adding this code to the end of the built-in-ds example:
                  Code:
                          IButton setEV = new IButton("Set Edit Value");
                          setEV.setLeft("80%");
                          setEV.draw();
                          setEV.addClickHandler(new ClickHandler() {
                  			
                  			@Override
                  			public void onClick(ClickEvent event) {
                  				
                  				boundList.setEditValue(0, "commonName", "FOO");
                  				
                  			}
                  		});
                  This draws a button which sets the edit value for some record/field on the grid - to test it out, load the modified example, click "Animals" in the left grid to bind to the Animals dataSource, use the context menu to hide the "Animal" field, then click the button.
                  Everything works as expected for me - no javascript error, and when I re-show the field the edit value is visible...

                  Can you try that test (in case it's a SGWT version difference) -- and if you don't see the bug, see if you can put together simple test case demonstrating this JS error?

                  Thanks

                  Comment


                    #10
                    I'm not seeing the JS error any longer when the field is hidden. Must have been something else I was doing. I think part of my confusion was in using a CellSavedHandler to calculate and update the other fields in the row. I've tried using a ChangedHandler but that gets fired after every keystroke as the field is being changed. I'll try a BlurHandler next. I need to get the field value after it is changed, not during the changing. In the case of one of the fields I need to take the user's new input value and potentially change it (rounding it up), so Blur sounds like the right event, unless there is a better approach.

                    A related question is about the Object returned by event.getValue() when the ChangedHandler is fired. On a ListGridFieldType.Integer the object returned by event.getValue() is a String, not an Integer. I have to use Integer.parseInt(event.getValue()) instead of casting it as an Integer. Why is that necessary?
                    Last edited by jay.l.fisher; 9 Oct 2010, 06:22.

                    Comment


                      #11
                      Hi Jay,
                      You can probably set changeOnKeypress to false for your editor for the field in question and then use a changed handler rather than relying on blur

                      Comment


                        #12
                        Did you ever figure anything out regarding the 'refreshCell' error? I'm also seeing it when I call 'endEditing'. And like you said, everything seems to work, there are just a bunch of errors in the console.

                        Thanks.

                        Comment


                          #13
                          [sorry, replied to wrong post at first]

                          We asked Jay a number of questions about his usage that ultimately caused him to implement some code fixes that got rid of the error. What would your answers be to the same questions?
                          Last edited by Isomorphic; 27 Oct 2010, 14:27.

                          Comment

                          Working...
                          X