Announcement

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

    ListGrid.getEditedRecord(int) returns null for cells storing objects

    Hi,

    Starting with SGWT 5.1 I noticed that ListGrid.getEditedRecord(int) returns null for cell storing objects. See below example: "concat" & "kv" columns are not editable, but "concat" is returned while calling getEditedRecord. "kv" is not.

    The log is obtained using SGWT 6.1d build 10.10.2016

    Code:
    package com.smartgwt.sample.showcase.client.grid.editing;
    
    import com.smartgwt.client.types.ListGridEditEvent;
    import com.smartgwt.client.types.ListGridFieldType;
    import com.smartgwt.client.util.SC;
    import com.smartgwt.client.widgets.Canvas;
    import com.smartgwt.client.widgets.grid.CellFormatter;
    import com.smartgwt.client.widgets.grid.ListGrid;
    import com.smartgwt.client.widgets.grid.ListGridField;
    import com.smartgwt.client.widgets.grid.ListGridRecord;
    import com.smartgwt.client.widgets.grid.events.EditorExitEvent;
    import com.smartgwt.client.widgets.grid.events.EditorExitHandler;
    import com.smartgwt.sample.showcase.client.PanelFactory;
    import com.smartgwt.sample.showcase.client.ShowcasePanel;
    
    public class GridEditByCellSample extends ShowcasePanel {
        private static final String DESCRIPTION = "<p><b>Click</b> on any cell to start editing. Use <b>Tab</b>, <b>Shift-Tab</b>," +
                "<b>Up Arrow</b>, and <b>Down Arrow</b> to move between cells.</p><p>Press <b>Enter</b> to save the current row" +
                "and dismiss the editors, or <b>Esc</b> to discard changes for the current cell and dismiss" +
                "the editors.</p>";
    
        public static class Factory implements PanelFactory {
            private String id;
    
            public ShowcasePanel create() {
                GridEditByCellSample panel = new GridEditByCellSample();
                id = panel.getID();
                return panel;
            }
    
            public String getID() {
                return id;
            }
    
            public String getDescription() {
                return DESCRIPTION;
            }
        }
    
        public Canvas getViewPanel() {
    
            ListGridField nameField = new ListGridField("countryName", "Country");
            nameField.setCanEdit(true);
            ListGridField populationField = new ListGridField("population", "Population");
            populationField.setType(ListGridFieldType.INTEGER);
            
            ListGridField concatField = new ListGridField("concat", "Concat");
            ListGridField kvField = new ListGridField("kv", "key value");
            kvField.setCellFormatter(new CellFormatter() {
                
                @Override
                public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
                    // TODO Auto-generated method stub
                    KeyValue kv = (KeyValue) record.getAttributeAsObject("kv");
                    return kv.key + " (" + kv.value + ")";
                }
            });
            
            final ListGrid countryGrid = new ListGrid();
            countryGrid.setFields(nameField, populationField, concatField, kvField);
    
            countryGrid.setData(new ListGridRecord[]{
                    createRecord("United States", 318000000),  
                    createRecord("China", 1357000000),  
            });
      
    //        countryGrid.setCanEdit(true);  
            countryGrid.setEditEvent(ListGridEditEvent.CLICK);  
            countryGrid.setEditByCell(true);
            
            countryGrid.addEditorExitHandler(new EditorExitHandler() {
                
                @Override
                public void onEditorExit(EditorExitEvent event) {
                    
                    ListGridRecord record = (ListGridRecord) countryGrid.getEditedRecord(event.getRowNum());
                    
                    SC.say("" + (record.getAttribute("concat")!=null) 
                            + (record.getAttribute("kv")!=null) 
                            + (record.getAttributeAsObject("kv")!=null));
                }
            });
    
            return countryGrid;
        }
    
        ListGridRecord createRecord(String countryName, int population) {
            ListGridRecord record = new ListGridRecord();
            record.setAttribute("countryName", countryName);
            record.setAttribute("population", population);
            record.setAttribute("concat", countryName + " (" + population + ")");
            record.setAttribute("kv", new KeyValue(countryName, population));
            return record;
        }
        
        class KeyValue
        {
            String key;
            int value;
            
            public KeyValue(String key, int value) {
                // TODO Auto-generated constructor stub
                this.key = key;
                this.value = value;
            }
        }
        
        public String getIntro() {
            return DESCRIPTION;
        }
    
    
    }
    Code:
    12:32:56.032:KDN6:DEBUG:gridEdit:isc_ListGrid_0:change detection: newValues: {}, oldValues: {__ref: {GWT Java Obj},
    __module: {GWT Module Obj},
    countryName: "United States",
    population: 318000000,
    concat: "United States (318000000)",
    kv: com.smartgwt.sample.showcase.client.grid.editing.GridEditByCellSample$KeyValue@b1}
    12:32:56.032:KDN6:INFO:gridEdit:isc_ListGrid_0:saveEdits: no actual change, not saving
    12:32:56.033:KDN6:INFO:gridEdit:isc_ListGrid_0:Starting editing at row 1, colNum 0
    12:32:56.033:KDN6:INFO:gridEdit:isc_ListGrid_0:hideInlineEditor for row with no edits - dropping edit values
    12:32:56.034:KDN6:DEBUG:GridBody:isc_ListGrid_0_body:delaying adjustOverflow: cell height changed
    12:32:56.049:KDN6:INFO:drawing:isc_TextItem_4[countryName]:About to clear this form item [Item removed / visibility changed].
    12:32:56.061:KDN6:INFO:drawing:isc_TextItem_4[countryName]:Form item cleared from within container widget isc_ListGrid_0_body
        FormItem.cleared() on [TextItem ID:isc_TextItem_4 name:countryName] @ ISC_Forms.js:836:576
        ListGrid._editItemsDrawingNotification(_1=>[TextItem ID:isc_TextItem_4 name:countryName], _2=>null, _3=>[GridBody ID:isc_ListGrid_0_body]) on[ListGrid ID:isc_ListGrid_0] @ ISC_Grids.js:1318:201
        ListGrid.refreshCellValue(_1=>0, _2=>0, _3=>true, _4=>undef) on[ListGrid ID:isc_ListGrid_0] @ ISC_Grids.js:1834:90
        ListGrid.refreshCell(_1=>0, _2=>0, _3=>true, _4=>undef) on[ListGrid ID:isc_ListGrid_0] @ ISC_Grids.js:1823:98
        ListGrid.refreshRow(_1=>0) on[ListGrid ID:isc_ListGrid_0] @ ISC_Grids.js:1838:116
        ListGrid.hideInlineEditor(_1=>false, _2=>true, _3=>undef) on[ListGrid ID:isc_ListGrid_0] @ ISC_Grids.js:1756:200
        ListGrid._startEditing(_1=>1, _2=>0, _3=>undef) on[ListGrid ID:isc_ListGrid_0] @ ISC_Grids.js:1714:152
        ListGrid._saveAndStartEditing(_1=>1, _2=>0, _3=>"tab") on[ListGrid ID:isc_ListGrid_0] @ ISC_Grids.js:2014:36
        ListGrid._changeEditCell(_1=>"tab", _2=>0, _3=>0, _4=>1, _5=>0) on[ListGrid ID:isc_ListGrid_0] @ ISC_Grids.js:1705:21
        ListGrid.cellEditEnd(_1=>"tab", _2=>undef) on[ListGrid ID:isc_ListGrid_0] @ ISC_Grids.js:1975:6
        ListGrid.editorKeyPress(_1=>[TextItem ID:isc_TextItem_4 name:countryName], _2=>"Tab", _3=>undef) on[ListGrid ID:isc_ListGrid_0] @ ISC_Grids.js:714:6
        itemKeyPress(_1=>[TextItem ID:isc_TextItem_4 name:countryName], _2=>"Tab", _3=>undef) on [DynamicForm ID:isc_DynamicForm_30] @ ISC_Grids.js:673:7014
        FormItem._fireKeyPressHandlers(_1=>[TextItem ID:isc_TextItem_4 name:countryName], _2=>[DynamicForm ID:isc_DynamicForm_30], _3=>"Tab", _4=>undef) on [TextItem ID:isc_TextItem_4 name:countryName] @ ISC_Forms.js:1291:74
        FormItem.handleKeyPress(_1=>Obj, _2=>Obj) on [TextItem ID:isc_TextItem_4 name:countryName] @ ISC_Forms.js:1283:38
        [c]Class.invokeSuper(_1=>null, _2=>"handleKeyPress", _3=>undef, _4=>undef, _5=>undef, _6=>undef, _7=>undef, _8=>undef, _9=>undef, _10=>undef, _11=>undef, _12=>undef, _13=>undef) on [TextItem ID:isc_TextItem_4 name:countryName] @ ISC_Core.js:275:93
        [c]Class.Super(_1=>"handleKeyPress", _2=>[object Arguments], _3=>undef) on [TextItem ID:isc_TextItem_4 name:countryName] @ ISC_Core.js:267:170
        TextItem.handleKeyPress(_1=>Obj, _2=>Obj) on [TextItem ID:isc_TextItem_4 name:countryName] @ ISC_Forms.js:1728:610
        [c]EventHandler.bubbleEvent(_1=>[TextItem ID:isc_TextItem_4 name:countryName], _2=>"keyPress", _3=>Obj, _4=>undef, _5=>undef) on [Class EventHandler] @ ISC_Core.js:2004:89
        [c]EventHandler.handleKeyPress(_1=>[object KeyboardEvent], _2=>undef) on [Class EventHandler] @ ISC_Core.js:1782:122
        EventHandler._handleNativeKeyDown(_1=>[object KeyboardEvent], _2=>undef) on [Class EventHandler] @ ISC_Core.js:1762:63
        [c]EventHandler.dispatch(_1=>[c]EventHandler.$j9(), _2=>[object KeyboardEvent]) on [Class EventHandler] @ ISC_Core.js:2082:108
        HTMLDocument.eval(event=>[object KeyboardEvent]) @ [no file]:3:123
    Ionut

    #2
    Any progress on this one?

    Thanks

    Comment


      #3
      This most likely has to do with using a Java Object instead of a simple value for PK. This is rare use case, and we plan to look at it eventually, but there are a lot of other higher priority items. If you need help more quickly, please purchase a Support plan.

      Comment

      Working...
      X