Wijmo Grid Formatting cell values on typing

Posted by: brzozowski.m24 on 23 November 2021, 5:13 am EST

  • Posted 23 November 2021, 5:13 am EST

    I'm looking for a solution for my case. I'm using wj-flex-grid component. In this component, I allow user to edit cells. On editing cell, I would like to change format of the number provided by user once user is passing data from the keyboard.
    For example, user wants to pass 1000000 and started with 1000 => and on the fly I would like to format this to 1,000 (separation coma) and keep typing another 0s so it finally should go to 1,000,000. I noticed it's working once user ended editing cell, but is it possible to make this on the fly (once user is still editing cell)?
    Thank you for response
  • Marked as Answer

    Replied 23 November 2021, 8:00 pm EST


    Yes, you may handle the prepareCellForEdit event of FlexGrid and add an keyup event listener to the activeEditor and update the input field value i.e cell value through parsing. Please refer to code snippet and sample link below demonstrating the same:

    theGrid.prepareCellForEdit.addHandler((s, e) => {
    if (s.activeEditor) {
    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/4sypvSznt0SZJ9injkwfOA/

  • Replied 23 November 2021, 8:25 pm EST

    Thank you very much! That's exactly what I need
Need extra support?

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

Learn More

Forum Channels