FlexSheet - Column maxLength property does not apply to pasted data

Posted by: holly.anderson on 10 October 2017, 7:06 am EST

    • Post Options:
    • Link

    Posted 10 October 2017, 7:06 am EST

    Hello,

    I’m using the maxLength property on the columns in a FlexSheet to restrict the length of values that users can enter. However, I noticed that users can get around this restriction by pasting a value that is longer than the specified maxLength in the cell. What is the proper way to prevent this from happening?

    Thanks,

    Holly

  • Posted 10 October 2017, 3:58 pm EST

    Hi Holly,

    The maxLength property set the maxLength for default editor that allows entering the limited character.

    You can handle pastingCell event to slice pasted data or cancel pasting if pasted data length is greater than maxLength.

    Please refer to the attached sample for the same that slice the data and allows only three characters for the country column.

    ~Manish Kr Gupta

    FlexSheet_ColumnMaxLength.zip

  • Posted 10 October 2017, 11:56 pm EST

    Hi Manish,

    I’m a bit confused about the sample you provided. If I copy ‘India’ from an external source (e.g. Notepad) and paste it into a cell in the Country column, the value is trimmed to ‘Ind’ as expected. But if I copy ‘India’ from a cell in the Country column and paste it into another cell, the value is not trimmed. Can you provide any further guidance?

    Thanks,

    Holly

  • Posted 11 October 2017, 8:21 pm EST

    Hi Holly,

    Thank you for reporting this issue. We are able to replicate the issue at our end and it seems a bug. Hence, this issue has been reported to the concerned team for further investigation with tracking id 291053.

    In the meantime, please use the following code snippet as a workaround.

    flex.pastingCell.addHandler(function(s,e){
                if(e.col==1){
                        e.cancel=true;
                        e.data=e.data.slice(0,flex.columns[e.col].maxLength);
                        s.setCellData(e.row,e.col,e.data);
                    }
                    
                });
    

    ~Manish

  • Posted 5 January 2018, 11:24 pm EST

    Hi,

    This issue has been found fixed with pre-release build version 5.20173.400. If you would like to verify the issue, you may download the pre-release build for testing purpose.

    http://prerelease.componentone.com/wijmo5/

    This build is not recommended to use for production since this is under QA process for next release.

    ~Manish

Need extra support?

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

Learn More

Forum Channels