Native way to handle char type data input in flexgrid column

Posted by: venkata.vimjam on 20 June 2018, 2:06 am EST

    • Post Options:
    • Link

    Posted 20 June 2018, 2:06 am EST

    Currently we are handling char type input data (only alphabets) by getting the data of the cell in cellEditEnded event and cleaning out the input.

    I was wondering if there is a better way to handle this natively ?

    I looked at DataType enum and char is not one of them.

  • Posted 20 June 2018, 10:54 pm EST

    Hi,

    DataType enum supports only the basic data types.

    If you would like a column to accept only the alphabets as input you can handle the keydown event and check if the key pressed is valid or not and if not then call preventDefault() to stop the grid from registering the event.

    Please refer to following code snippet:

    grid.hostElement.addEventListener('keydown',(e)=>{
    	if(grid.columns[grid.selection.col].binding=="country"&&!isAlphabetKey(e.keyCode)&&!isSpe		cialKey(e.keyCode)){
    		e.preventDefault();
    	}
    });
    

    You may refer to the following sample:- https://stackblitz.com/edit/js-u41amn?file=index.js

    ~Manish

Need extra support?

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

Learn More

Forum Channels