16

I placed scrollIntoView() to make my grid scroll visible. When I add new grid in gridContainer so I using this method. This is working I can check from debugger. my scrollIntoView()

grid.body.dom.scrollIntoView();

But once it reached in defer function it not scrollIntoView() functioning. Can anybody please suggest how to skip this. What defer do and how to skip this. Also I am using grid.focus() and again same thing is happening. Grid is coming into view but after come out from debugger no showing into view.

defer: function(fn, millis, scope, args, appendArgs) {
  fn = Ext.Function.bind(fn, scope, args, appendArgs);
  if (millis > 0) {
    return setTimeout(function() {
      if (Ext.elevateFunction) {
        Ext.elevateFunction(fn);
      } else {
        fn();
      }
    }, millis);
  }
  fn();
  return 0;
},
ThisaruG
  • 3,222
  • 7
  • 38
  • 60
David
  • 4,266
  • 8
  • 34
  • 69
  • 1
    `defer` is essentially like a `setTimeout`. However I'm not really clear on the rest of your question. – Evan Trimboli Jan 30 '17 at 10:19
  • @EvanTrimboli What I need to do if I don't want timeout. I am giving `grid.body.dom.scrollIntoView();` in my grid after some time this code is not working. – David Jan 30 '17 at 10:25
  • 2
    There's not enough information, what is causing the `defer` call? Why aren't you using the scroller API? `grid.body.dom` isn't the right thing to be scrolling. – Evan Trimboli Jan 30 '17 at 10:28
  • ok, let me check scroll APIs. – David Jan 30 '17 at 10:29
  • 1
    I can not use any other Api because "Scrolls this element into view within the passed container." is only possible by `scrollIntoView` – David Jan 30 '17 at 10:44
  • 1
    That doesn't sound right. The grid body itself isn't scrollable. – Evan Trimboli Jan 30 '17 at 10:51
  • yes, But I need to make scrollable with respect to parent container. and this only I found in doc of scrollIntoView – David Jan 30 '17 at 10:53
  • 4
    Could you create a [fiddle](https://fiddle.sencha.com/#view/editor) that shows your problem? – scebotari66 Feb 01 '17 at 14:31

1 Answers1

3

A workaround would be not to scroll to the component, but to use the card layout for the center container and display the new grid on an other card.

var centerCt;  // reference to your center container
var centerLayout = centerContainer.getLayout();
var newGrid = Ext.create('Ext.grid.Panel', {});
centerCt.add(newGrid);
centerLayout.setActiveItem(newGrid);

I created a Sencha Fiddle.

And-y
  • 1,519
  • 2
  • 22
  • 33
  • I am using vbox and when I changing to card no second grid is loading. Well let me try this whatever you written in answer and get back to you in some time. – David Feb 03 '17 at 13:15
  • This won't work, because at once I am showing only one grid here. I need my panel to be scrollable. – David Feb 07 '17 at 05:31