SlickGrid icon indicating copy to clipboard operation
SlickGrid copied to clipboard

Paste scroll on bottom of page

Open Yrtiop opened this issue 8 years ago • 0 comments

When you paste in the grid everything works fine except you are scrolled on the bottom of the page, you can see it in the demo.

It's caused by this function of slick.cellexternalcopymanager.js :

    function setDataItemValueForColumn(item, columnDef, value) {
      if (_options.dataItemColumnValueSetter) {
        return _options.dataItemColumnValueSetter(item, columnDef, value);
      }

      // if a custom setter is not defined, we call applyValue of the editor to unserialize
      if (columnDef.editor){
        var editorArgs = {
          'container':$("body"),  // a dummy container
          'column':columnDef,
          'position':{'top':0, 'left':0},  // a dummy position required by some editors
          'grid':_grid
        };
        var editor = new columnDef.editor(editorArgs);
        editor.loadValue(item);
        editor.applyValue(item, value);
        editor.destroy();
      }
    }

The container used is "body", so the input is created in the bottom of the body then is focused, so we scroll to it. I fixed it with this :

'container':$("<p>"), // a dummy container

Yrtiop avatar Nov 09 '16 09:11 Yrtiop