Announcement

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

    value set from formatEditorValue not recognized with getEditValue

    Hi there,

    I’m trying to use a two-column ListGrid. I am using a selectionUpdated event to check for changed values and send them to my server - afterwards, I call saveAllEdits. To have a default value in the first column I implemented a simple formatEditorValue for the first column which returns “Foo” if the records value is undefined. To detect the changes, I iterate over the changed rows and their fields to determine which of them have changed.

    If I edit a field in the second column, any value beyond the first generated by the formatEditorValue does not seem to get recognized by the row’s changed fields. You can find my code below - is this intended behavior? Click image for larger version

Name:	Animation 64.gif
Views:	90
Size:	124.8 KB
ID:	240625

    The issue is reproducible in the latest Chrome (53.0.2785.143 m), Firefox (47.0.1) and IE (10.0.9200.17609) with nightly build SmartClient_v110p_2016-10-05_Pro

    Best regards
    Code:
    isc.ListGrid.create({
        "ID" : "demoListGrid",
        "width" : "300",
        "height" : "180",
        "canEdit" : true,
        "autoSaveEdits" : false,
        "selectionUpdated" : function () {
            var editRowsArray = demoListGrid.getAllEditRows();
            console.log(editRowsArray);
            for (changedRowIndex = 0; changedRowIndex < editRowsArray.length; changedRowIndex++) {
                var changedRecordIndex = editRowsArray[changedRowIndex];
                var record = demoListGrid.getRecord(changedRecordIndex);
                var gridFields = demoListGrid.getAllFields();
                for (gridFieldIndex = 0, visibleGridFieldIndex = 0; gridFieldIndex < gridFields.length; gridFieldIndex++, visibleGridFieldIndex++) {
                    var gridField = gridFields[gridFieldIndex];
                    var editValue = demoListGrid.getEditValue(changedRecordIndex, visibleGridFieldIndex);
                    outputCanvas.setContents(outputCanvas.getContents() + "</br>" + gridField.name + " := " + editValue);
                }
            }
            setTimeout(function () {
                demoListGrid.saveAllEdits();
            }, 1)
        },
        "fields" :
        [{
                "name" : "fooField",
                "title" : "fooField",
                "type" : "text",
                "width" : 130,
                "formatEditorValue" : function (value, record, rowNum, colNum, grid) {
                    if (value == undefined) {
                        return "Foo"
                    } else {
                        return value
                    }
                },
                "canEdit" : true
            }, {
                "name" : "otherField",
                "title" : "otherField",
                "type" : "text",
                "width" : 130,
                "canEdit" : true
            }
        ],
        "data" : [{}, {}, {}
        ]
    }),
    isc.Canvas.create({
        "ID" : "outputCanvas",
        left : 300,
        width : 400
    })

    #2
    Hi,
    are there any news on this?

    Comment


      #3
      Defining a formatEditorValue() without a corresponding parseEditorValue() is invalid usage, and can give inconsistent results.

      You need a parseEditorValue() to have a consistent interpretation of what it means when "Foo" is found in the field - specifically, did you intend that to be treated as null/undefined (since you show it when the underlying field value is null/undefined) or is it meant to be treated as user input? By defining a parseEditorValue() function, you define what is supposed to happen here; without having done so, the interpretation is ambiguous and can differ per browser or according to how focus moves into the field.

      Comment

      Working...
      X