[OPEN] [#312] gridpanel scroll position

Page 1 of 2 12 LastLast
  1. #1

    [OPEN] [#312] gridpanel scroll position

    Hi,

    I have GridPanel with fixed height with periodically data updating:

    this.record.set('field_name', value);
    after this code scroll resets to top of grid.

    PreserveScrollOnRefresh and InvalidateScrollerOnRefresh properties don't help.
    And: is it possible to preserve scroll position when using filterBy method in store?

    Thanks, Alex
    Last edited by Daniil; Aug 02, 2013 at 5:51 AM. Reason: [OPEN] [#312]
  2. #2
    Hi Alex,

    I cannot reproduce it with the following test case.

    Tested with the Ext.NET v2.2 release and the trunk in Chrome, FireFox and IE9.

    Example
    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                Store store = this.GridPanel1.GetStore();
    
                object[] data = new object[50];
    
                for (int i = 0; i < 50; i++)
                {
                    data[i] = new { test = "Test " + i };
                }
                
                store.DataSource = data;
            }
        }
    </script>
    
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    
        <script>
            var count = 0;
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
    
            <ext:TaskManager runat="server">
                <Tasks>
                    <ext:Task>
                        <Listeners>
                            <Update Handler="var record = App.GridPanel1.getStore().getAt(count++);
                                            
                                             if (record) {
                                                record.set('test', 'new' + count);
                                             }" />
                        </Listeners>
                    </ext:Task>
                </Tasks>
            </ext:TaskManager>
    
            <ext:GridPanel ID="GridPanel1" runat="server" Height="200">
                <Store>
                    <ext:Store runat="server">
                        <Model>
                            <ext:Model runat="server">
                                <Fields>
                                    <ext:ModelField Name="test" />
                                </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server">
                    <Columns>
                        <ext:Column runat="server" Text="Test" DataIndex="test" />
                    </Columns>
                </ColumnModel>
            </ext:GridPanel>
        </form>
    </body>
    </html>
  3. #3
    Hi Daniil,

    Yes, your example work as I need. The only one difference with my code that my GridPanel has MaxHeight property (set MaxHeight in your sample and you'll see how scroll going up). It's nessesary in my project, I want change height grid depending on rows count. If I set MaxHeight gridpanel has correct behaviour,but scroll is going up after every data updating. And vise versa, if I set Height instead MaxHeight - scroll works fine but grid height calculates as don't I need. So, I can't find correct solution in this case.

    I see only one solution - calculate grid height before first render and after every update data or filterBy method.
    Last edited by retto; Jul 16, 2013 at 6:39 PM.
  4. #4
    I tried with MaxHeight="100" and MaxHeight="500" in my test case in FireFox and IE, but cannot reproduce.
  5. #5
    It's very strange. I copied your code and changed Height -> MaxHeight and scroll is going up after update (Chrome, IE9)
    I use Ext.Net 2.2.0.40838. Do you have any suggestions why it happens?

    Or maybe I'm incorrect described problem. The problem is when you scroll gridpanel and in this time grid is updates - scroll jump to top of grid.
    Last edited by retto; Jul 31, 2013 at 8:24 PM.
  6. #6
    I think it's problem with Ext.Net 2.2.0 because with Ext.Net 2.1.1 your sample works correct but not with 2.2.0
  7. #7
    Quote Originally Posted by retto View Post
    and changed Height -> MaxHeight
    Reproduced this way. Reported to Sencha.
    http://www.sencha.com/forum/showthread.php?269074
  8. #8
    Sencha opened a bug. We created an Issue to track it.
    https://github.com/extnet/Ext.NET/issues/312
  9. #9
    Hi again!

    I've another one problem with scrollbar, I make store.filterBy periodically. To prevent scroll jump I set gridpanel.InvalidateScrollerOnRefresh="False". Works fine but if select row in gridpanel and scrolling grid to hide this selected row and in this time store.filterBy called - scroll is jump to selected row. How avoid scroll jumping to selected row?
  10. #10
    Please provide a full test case.
Page 1 of 2 12 LastLast

Similar Threads

  1. [CLOSED] TreeGrid scroll position after refresh
    By agonzalez in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Mar 14, 2013, 3:14 PM
  2. Maintain scroll position in dataview
    By dotnet in forum 1.x Help
    Replies: 0
    Last Post: Jan 28, 2013, 10:10 AM
  3. [CLOSED] [1.2] GridPanel and Store reload scroll position?
    By Timothy in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Oct 17, 2011, 5:45 PM
  4. [CLOSED] Grid - scroll position
    By jwf in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: May 26, 2011, 11:13 PM
  5. multi select scroll position
    By [WP]joju in forum 1.x Help
    Replies: 1
    Last Post: Apr 13, 2009, 12:13 PM

Tags for this Thread

Posting Permissions