Author Topic: Copy paste in integer column  (Read 2469 times)

cijojohn

  • Pro Ultimate
  • Jr. Member
  • *
  • Posts: 73
    • View Profile
Copy paste in integer column
« on: October 04, 2017, 10:54:50 am »
Hello Team,

If we try to paste in integer columns if value is 1,000 i.e integer value with 'comma' it is pasting only 1.
I have replicated this in your demo also by making order id column as editable and integer.

https://paramquery.com/pro/demos/editing_custom

Please Suggest.

Thanks,

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Copy paste in integer column
« Reply #1 on: October 05, 2017, 02:15:12 pm »
Please use beforePaste event to convert formatted numbers into valid integers/floats.

Code: [Select]
            beforePaste: function(evt, ui){
                //debugger;
                //beforePaste event can be used to modify/sanitize pasted data.
                var CM = this.getColModel(),
                    rows = ui.rows,
                    area = ui.areas[0],
                    //r1 = area.r1,
                    c1 = area.c1;
                for(var i=0; i<rows.length; i++){
                    var row = rows[i];
                    for(var j=0;j<row.length;j++){
                        var column = CM[j+c1],
                            dt = column.dataType;
                        if(dt=="integer" || dt == "float"){
                            row[j] = row[j].replace(/[^(\d|\.)]/g,"");
                        }
                    }
                }
            },

cijojohn

  • Pro Ultimate
  • Jr. Member
  • *
  • Posts: 73
    • View Profile
Re: Copy paste in integer column
« Reply #2 on: October 05, 2017, 04:38:08 pm »
Does this solution work in 4.0 only?
We only see, rows property in ui object in 3.3.5

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Copy paste in integer column
« Reply #3 on: October 16, 2017, 01:05:32 pm »
Yes this solution works only in >= 4.x