Author Topic: Copy and Paste functionality only for Existing row  (Read 2822 times)

bsolteam

  • Pro Deluxe
  • Full Member
  • *
  • Posts: 107
    • View Profile
Copy and Paste functionality only for Existing row
« on: April 09, 2015, 06:49:50 pm »
Hi Team,

Copy and Paste functionality is working very nice. But in my case this functionality should happen only for existing rows. It should not create new rows. In attached file 14 rows are already existed. If I copy 7 rows and pasted in last row it created 6 new rows. I want to restrict the creation of new rows. Is there any options to restrict the creation of new rows and paste only in existing rows.

Thanks in advance.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: Copy and Paste functionality only for Existing row
« Reply #1 on: April 13, 2015, 05:18:42 pm »
Please use beforeValidate event to process the pasted rows.

Code: [Select]
               beforeValidate: function(evt, ui){
                   //debugger;
                   if(ui.source =='paste'){
                       var rowList = ui.rowList;
                       for(var i = rowList.length - 1 ; i >= 0 ; i-- ){
                           var rowL = rowList[i];
                           if(rowL.oldRow == null){                           
                               rowList.splice( i , 1 );
                           }
                       }
                   }
               }

Example jsfiddle. http://jsfiddle.net/cjshzj8o/
« Last Edit: April 14, 2015, 12:03:38 am by paramquery »

nebels

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Copy and Paste functionality only for Existing row
« Reply #2 on: July 22, 2015, 10:12:35 am »
Thanks heaps for your quick reply!