Remove specific handler

Posted by: brzozowski.m24 on 26 November 2021, 7:18 am EST

  • Posted 26 November 2021, 7:18 am EST

    Hello,

    I posted a topic with my problem here: https://www.grapecity.com/forums/wijmo/wijmo-grid-formatting-cell

    Everything seems to be working fine, but in my case I also need to remove this specific handler on Cell Edit ended.

    I’m not sure how to point to specific handler to be removed for other cells.

    In my case, I have different type of columns like: Number, Integer, Percentage etc.

    In my case I’m adding handler for formatting Number, but I want to remove this specific handler once I’m formatting Percentage column type cell.

    Is it possible to point to specific handler which should be removed?

    Thank you

  • Posted 29 November 2021, 8:41 am EST

    Hello,

    The prepareCellForEdit event gets attached to the cell when it enters the edit mode and automatically gets removed from that cell after the cell edit ends. As per my understanding, you want to restrict the formatting only to the columns of Number dataType if so then you may add a condition for that in the prepareCellForEdit handler itself to prevent it from getting executed for certain columns. Please refer to the code snippet and updated sample link below for reference:

    
        theGrid.prepareCellForEdit.addHandler((s, e) => {
            if (s.activeEditor && s.columns[e.col].dataType == wjcCore.DataType.Number) {
                s.activeEditor.addEventListener('keyup', function (evt) {
                    let val = this.value.replace(/\D/g, '')
                    if (val != "") {
                        var n = parseInt(val, 10);
                        s.activeEditor.value = n.toLocaleString()
                    }
                }, false);
            }
        })
    
    

    Sample link: https://jscodemine.grapecity.com/share/QR5QM-RKEEG0hlXbLfN9jQ/

    Regards

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels