Announcement

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

  • How to make a startEditing another cell inside of an editorExit?

    I am trying to start editing another cell inside of an editorExit in a ListGrid, but my code stays in an infinite loop. There is another candidate event: cellChanged, but I cannot use it because I will save the changes massively. According the documentation I could call startEditing inside of editorExit to implement custom navigation in a ListGrid (see the below paragraph, specially the last sentence):

    Boolean editorExit (editCompletionEvent, record, newValue, rowNum, colNum) [String Method]
    Callback fired when the user attempts to navigate away from the current edit cell, or complete the current edit. Return false from this method to cancel the default behavior (Saving / cancelling the current edit / moving to the next edit cell).
    This callback is typically used to dynamically update values or value maps for related fields (via setEditValue() and setEditorValueMap() respectively, or to implement custom navigation (via startEditing(rowNum,colNum).
    I am using SmartClient v11.0p_2016-03-31/LGPL Deployment.
    I will really appreciate any help on this topic.

    This is the piece of my code:

    Code:
        isc.ListGrid.create({
            ID: "tarjetaBoletoGrid",
            dataSource: tarjetaBoletoDataSource,
            fields: [
                {name: "puntoControl", title: "Control/Parada", canEdit: false,
                    showGridSummary: true, summaryFunction: "title", summaryValueTitle: "TOTAL"},
                {name: "numeroFinal1", showGridSummary: true, summaryFunction: "count"},
                {name: "numeroFinal2", showGridSummary: true, summaryFunction: "count"},
                {name: "numeroFinal3", showGridSummary: true, summaryFunction: "count"},
                {name: "numeroFinal4", showGridSummary: true, summaryFunction: "count"},
                {name: "numeroFinal5", showGridSummary: true, summaryFunction: "count"},
                {name: "numeroFinal6", showGridSummary: true, summaryFunction: "count"},
                {name: "numeroFinal7", showGridSummary: true, summaryFunction: "count"},
                {name: "numeroFinal8", showGridSummary: true, summaryFunction: "count"},
                {name: "numeroFinal9", showGridSummary: true, summaryFunction: "count"},
                {name: "numeroFinal10", showGridSummary: true, summaryFunction: "count"}
            ],
            alternateRecordStyles: false,
            showRowNumbers: true,
            showGridSummary: true,
            autoFetchData: false,
            canEdit: true,
            editEvent: "click",
            editByCell: true,
            autoSaveEdits: false,
            modalEditing: true,
            listEndEditAction: "done",
            enterKeyEditAction: "nextRow",
            getEditorProperties: function(field) {
                return {
                    editorType: "text",
                    required: true,
                    focusInItem: function() {
                        var len = this.getValue().length;
                        this.setSelectionRange(len-3, len);
                    }
                }
            },
            editorExit: function(editCompletionEvent, record, newValue, rowNum, colNum) {
                if (newValue !== undefined) {
                    var preValue = (rowNum == 0 ? record["numeroInicial"+(colNum-1)] : this.getEditedCell(rowNum-1, colNum));
                    if (parseInt(newValue) < parseInt(preValue)) {
                        isc.warn("El n&uacute;mero del boleto no puede ser inferior al del anterior punto de control.");
                        return false;
                    } else {
                        for (var i = rowNum+1; i < this.getTotalRows(); i++) {
                            this.setEditValue(i,colNum,newValue);
                        }
                    }
                }
                if (rowNum+1 == this.getTotalRows()) {
                    if (colNum+1 == this.fields.size()) {
                        if (this.startEditing(0,2,true)) {
                            console.log("Moviendo editor");
                        }
                    } else {
                        if (this.startEditing(0,colNum+1,true)) {
                            console.log("Moviendo editor");
                        }
                    }
                }
                return true;
            },
            dataArrived: configColumnsTarjetaBoletoGrid,
            selectionType: "single",
            headerHeight: 60,
            width: "100%",
            height: "*"
        });
    Last edited by sashir; 23rd May 2016, 11:56.
Working...
X