Announcement

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

    #46
    Originally posted by Isomorphic
    Are you trying to see the value before or after the canToggle behavior has switched it? Because some events fire before (Change), some after (Changed).
    In the example above, i set the canToggle property to the field before any events are fired. I am using the onRecordClick event to print the value of the edited record.

    So it would appear that the onRecordClick event fires before the value is changed? Is there a better event to key off of to view the value of the Record from grid.getEditedRecord(event.getRecordNum()) after the value has been changed?

    Comment


      #47
      Again, Changed is after. If you have any trouble with that, check if this happens without your skin customizations. Maybe you have the media reversed.

      Comment


        #48
        More errors upon going deeper into this issue.

        Code:
        private ListGrid grid;
        
            public void onModuleLoad() {
                HLayout layout = new HLayout();  
                layout.setWidth(300);
                layout.setHeight(200);
                layout.setMembersMargin(20);
        
                grid = new ListGrid();
                
                ListGridRecord record1 = new ListGridRecord();
                record1.setAttribute("one", "1");
                record1.setAttribute("two", "1");
                record1.setAttribute("three", "1");
        
                ListGridRecord record2 = new ListGridRecord();
                record2.setAttribute("one", "2");
                record2.setAttribute("two", "2");
                record2.setAttribute("three", "2");
        
                ListGridRecord record3 = new ListGridRecord();
                record3.setAttribute("one", "3");
                record3.setAttribute("two", "3");
                record3.setAttribute("three", "3");
        
                ListGridRecord[] records = new ListGridRecord[3];
                records[0] = record1;
                records[1] = record2;
                records[2] = record3;
        
                ListGridField field0 = new ListGridField("Select");
                field0.setType(ListGridFieldType.BOOLEAN);
                field0.setCanEdit(Boolean.TRUE);
                field0.setCanToggle(Boolean.TRUE);
                field0.addChangedHandler(new ChangedHandler() {
        
                    public void onChanged(ChangedEvent event) {
                        
                        GWT.log("col:" + event.getColNum() + " row:" + event.getRowNum(), null);
        
                    }
                });
        
        
                ListGridField field1 = new ListGridField("one", "one");
                ListGridField field2 = new ListGridField("two", "two");
                ListGridField field3 = new ListGridField("three", "three");
                ListGridField[] fields = new ListGridField[4];
                fields[0] = field0;
                fields[1] = field1;
                fields[2] = field2;
                fields[3] = field3;
        
        
                grid.setAutoFetchData(Boolean.FALSE);
                grid.setEditEvent(ListGridEditEvent.NONE);
                grid.setAutoSaveEdits(Boolean.FALSE);
                grid.setFields(fields);
                grid.setData(records);
        
        
                layout.addMember(grid);
        
                DynamicForm df = new DynamicForm();
                CheckboxItem check = new CheckboxItem("checkbox1", "Check");
                df.setItems(check);
                layout.addMember(df);
        
        
                layout.draw();
            }
        The GWT.log statement in the onChanged callback above is throwing errors:
        Code:
        Uncaught JavaScript exception [com.google.gwt.core.client.JavaScriptException: (TypeError): 'item.colNum' is null or not an object
        Uncaught JavaScript exception [com.google.gwt.core.client.JavaScriptException: (TypeError): 'item.colNum' is null or not an object
         number: -2146823281
         number: -2146823281
         description: 'item.colNum' is null or not an object
         description: 'item.colNum' is null or not an object
                at com.smartgwt.client.widgets.grid.events.ChangedEvent.getColNum(Native Method)
                at com.smartgwt.client.widgets.grid.events.ChangedEvent.getColNum(Native Method)
                at org.yournamehere.client.MainEntryPoint$1.onChanged(MainEntryPoint.java:121)
                at com.smartgwt.client.widgets.grid.events.ChangedEvent.dispatch(ChangedEvent.java:97)
                at com.smartgwt.client.widgets.grid.events.ChangedEvent.dispatch(ChangedEvent.java:1)
                at com.google.gwt.event.shared.HandlerManager$HandlerRegistry.fireEvent(HandlerManager.java:65)
                at com.google.gwt.event.shared.HandlerManager$HandlerRegistry.access$1(HandlerManager.java:53)
                at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:178)
                at com.smartgwt.client.core.DataClass.fireEvent(DataClass.java:237)] in http://localhost:8084/WebApplication1/org.yournamehere.Main/hosted.html?org_yournamehere_Main, line 8
        Please advise.

        Comment


          #49
          When toggling, there's no FormItem involved because the row does not enter edit mode. getItem() will return null. You can get the colNum and rowNum via direct calls to the grid (getEditRow() / getEditCol()).

          Note we'll got ahead and make it so this API works regardless (using the APIs we just suggested you use).

          Comment


            #50
            Originally posted by Isomorphic
            When toggling, there's no FormItem involved because the row does not enter edit mode. getItem() will return null. You can get the colNum and rowNum via direct calls to the grid (getEditRow() / getEditCol()).

            Note we'll got ahead and make it so this API works regardless (using the APIs we just suggested you use).
            Could you please be explicit on the API's you suggested? I have been working on this issue for quite some time, and this thread is quite long, I would like to be clear as to what to expect? (thanks in advance)

            Comment


              #51
              "direct calls to the grid (getEditRow() / getEditCol())" was not explicit enough?

              The APIs are ListGrid.getEditRow() and ListGrid.getEditCol().

              Comment


                #52
                In my last example it was the

                Code:
                field0.addChangedHandler(new ChangedHandler() {
                
                            public void onChanged(ChangedEvent event) {
                                
                                GWT.log("col:" + event.getColNum() + " row:" + event.getRowNum(), null);
                
                            }
                        });
                event.getColNum() and event.getRowNum() that was throwing errors?

                Comment


                  #53
                  So is this the way I should be reading your intended API usage?

                  Code:
                  field0.addChangedHandler(new ChangedHandler() {
                  
                              public void onChanged(ChangedEvent event) {
                  
                                  GWT.log("col:" + grid.getEditCol() + " row:" + grid.getEditRow(), null);
                              }
                          });
                  Currently both getEditCol and getEditRow return -1 which is what I assume you are intending to fix?

                  My last complete code example in posting #48 shows event.getColNum() and event.getRowNum() throwing errors. Wouldn't it be safer to get the Row and Column number from the event that is passed into the ChangedHandler callback?

                  Comment


                    #54
                    Originally posted by Isomorphic
                    Are you trying to see the value before or after the canToggle behavior has switched it? Because some events fire before (Change), some after (Changed).
                    What event would you recommend given what we are trying to do?

                    Comment


                      #55
                      Sorry, thinko in previous suggestion. getEditRow()/getEditCol() do not apply because this is just a toggle field and the inline editors are not active (hence -1).

                      The Changed event fires after the toggle has taken place. Use getEventRow() / getEventColumn() to find out the row and column clicked.

                      The change we plan to make is to have ChangedEvent.getRowNum()/getColNum() work for toggle fields (they already work when inline editing is active).

                      Comment


                        #56
                        What build can I expect to see this in?

                        Comment


                          #57
                          We'll let you know when it's in.

                          Comment


                            #58
                            The change has been made in the latest nightly.

                            Comment


                              #59
                              Where do I register the OnChangedHandler? I do not see any ListGrid methods to register this callback?

                              Comment


                                #60
                                Still on ListGridField as in your previously posted sample.

                                Comment

                                Working...
                                X