ce icon indicating copy to clipboard operation
ce copied to clipboard

move row down bug

Open TsePakKwan opened this issue 7 years ago • 2 comments

hi @paulhodel, I try to use jexcel v3 move row function, then find a bug. move row to up is not problem ( table.moveRow(3, 0); ). However, when I move the row to down (table.moveRow(3, 0);). It should be move the first row to the forth position, but move to row 3. then will move wrong row and the spreadsheet y coordinate will wrong. could you solve it?

detail please refer below example. https://jsfiddle.net/tsepakkwan/0xucfrah/5/ 1562552293090

thanks your amazing project.

TsePakKwan avatar Jul 08 '19 02:07 TsePakKwan

I saw the source code jexcel.js. Lines 2845 to 2856, If my understanding is correct, changing to the code below will solve this problem.

 if (! ignoreDom) {   if (Array.prototype.indexOf.call(obj.tbody.children, obj.rows[d]) >= 0) {     if( o > d ){       //move up       obj.tbody.insertBefore(obj.rows[o], obj.rows[d]);      }else{       //move down       obj.tbody.insertBefore(obj.rows[o], obj.rows[d+1]);      }   } else {    obj.tbody.removeChild(obj.rows[o]);   }  }  // Place references in the correct position  if( o > d ){   //move up   obj.rows.splice(d, 0, obj.rows.splice(o, 1)[0]);   obj.records.splice(d, 0, obj.records.splice(o, 1)[0]);   obj.options.data.splice(d, 0, obj.options.data.splice(o, 1)[0]);  }else{   //move down   obj.rows.splice(d+1, 0, obj.rows.splice(o, 1)[0]);   obj.records.splice(d+1, 0, obj.records.splice(o, 1)[0]);   obj.options.data.splice(d+1, 0, obj.options.data.splice(o, 1)[0]);  }

TsePakKwan avatar Jul 08 '19 07:07 TsePakKwan

It has been fixed.

pphod avatar Jul 08 '19 22:07 pphod