[CLOSED] Row Editor and horizontal scroll bar when RTL is true

  1. #1

    [CLOSED] Row Editor and horizontal scroll bar when RTL is true

    Hello,

    I have a gridpanel in a viewport with RTL true, the grid contains row editor and horizontal scroll bar.
    when clicking to add a new row tho horizontal scroll goes to left end of the grid.
    Here is a sample code and attached screenshots that shows before add and after begin add.

    <%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
    
    
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
    
    
        <title></title>
        <link href="/resources/css/examples.css" rel="stylesheet" />
    
          <style>
             .x-column-header {
               font       :bold 14px 'Tahoma',Times, serif !important;
               text-align:center !important;
               vertical-align:middle !important;
               height:38px;
            }
    
             .x-column-header-inner .x-column-header-text {
                white-space:nowrap;
            }
               
        </style>
    
       
        <script>
    
    
            
    
    
            var addEmployee = function () {
                var grid = App.GridPanel1,
                    store = grid.getStore();
    
                grid.editingPlugin.cancelEdit();
    
                store.getSorters().removeAll(); // We have to remove sorting to avoid auto-sorting on insert
                grid.getView().headerCt.setSortState(); // To update columns sort UI
    
                store.insert(0, {
                    name: 'New Guy',
                    email: 'new@ext.net',
                    start: Ext.Date.clearTime(new Date()),
                    salary: 50000,
                    active: true
                });
    
                grid.editingPlugin.startEdit(0, 0);
            };
    
            var removeEmployee = function () {
                var grid = App.GridPanel1,
                    sm = grid.getSelectionModel(),
                    store = grid.getStore();
    
                grid.editingPlugin.cancelEdit();
                store.remove(sm.getSelection());
    
                if (store.getCount() > 0) {
                    sm.select(0);
                }
            };
        </script>
    
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" ID="ResourceManager1" >
                <Listeners>
                    <DocumentReady Handler="App.direct.BindGridPanel();" />
                </Listeners>
            </ext:ResourceManager>
    
            <ext:Viewport runat="server" ID="VP1" RTL="true" Layout="BorderLayout" >
                 <Items>
    
    
    
                      
             <ext:GridPanel
                ID="GridPanel1"
                runat="server"
                Frame="true"
                 Region="Center" >
                <Store>
                    <ext:Store ID="Store1" runat="server">
                        <Sorters>
                            <ext:DataSorter Property="salary" />
                        </Sorters>
                        <Model>
                            <ext:Model runat="server" Name="Employee">
                                <Fields>
                                    <ext:ModelField Name="name" ServerMapping="Name" Type="String" />
                                    <ext:ModelField Name="email" ServerMapping="Email" Type="String" />
                                    <ext:ModelField Name="start" ServerMapping="Start" Type="Date" />
                                    <ext:ModelField Name="salary" ServerMapping="Salary" Type="Float" />
                                    <ext:ModelField Name="active" ServerMapping="Active" Type="Boolean" />
                                </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Store>
                <Plugins>
                     <ext:GridFilters runat="server" />
                    <ext:RowEditing runat="server" ClicksToMoveEditor="1" AutoCancel="false" />
                </Plugins>
                <TopBar>
                    <ext:Toolbar runat="server">
                        <Items>
                            <ext:Button runat="server" Text="Add Employee" Icon="UserAdd">
                                <Listeners>
                                    <Click Fn="addEmployee" />
                                </Listeners>
                            </ext:Button>
                            <ext:Button
                                ID="btnRemoveEmployee"
                                runat="server"
                                Text="Remove Employee"
                                Icon="UserDelete"
                                Disabled="true">
                                <Listeners>
                                    <Click Fn="removeEmployee" />
                                </Listeners>
                            </ext:Button>
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <ColumnModel>
                    <Columns>
                        <ext:RowNumbererColumn runat="server" Width="50" />
                        <ext:Column runat="server"
                            Text="Name"
                            DataIndex="name"
                             MinWidth="300">
                            <Editor>
                                <ext:TextField runat="server" AllowBlank="false" />
                            </Editor>
                        </ext:Column>
                        <ext:Column runat="server" Text="Email" DataIndex="email" Width="300">
                            <Editor>
                                <ext:TextField runat="server" AllowBlank="false" Vtype="email" />
                            </Editor>
                        </ext:Column>
                        <ext:DateColumn runat="server"
                            Text="Start Date"
                            DataIndex="start"
                            Format="MM/dd/yyyy"
                            Width="300">
                            <Editor>
                                <ext:DateField
                                    runat="server"
                                    AllowBlank="false"
                                    Format="MM/dd/yyyy"
                                    MinDate="01.01.2006"
                                    MinText="Can not have a start date before the Company existed."
                                    MaxDate="<%# DateTime.Now %>"
                                    AutoDataBind="true"
                                    />
                            </Editor>
                        </ext:DateColumn>
                        <ext:NumberColumn
                            runat="server"
                            Text="Salary"
                            DataIndex="salary"
                            Format="$0,0"
                            Align="Center" Width="300">
                            <Editor>
                                <ext:NumberField
                                    runat="server"
                                    AllowBlank="false"
                                    MinValue="1"
                                    MaxValue="150000"
                                    />
                            </Editor>
                        </ext:NumberColumn>
                        <ext:CheckColumn
                            runat="server"
                            Text="Active?"
                            DataIndex="active"
                            Width="300">
                            <Editor>
                                <ext:Checkbox runat="server" Cls="x-grid-checkheader-editor" />
                            </Editor>
                        </ext:CheckColumn>
                    </Columns>
                </ColumnModel>
                <Listeners>
                    <SelectionChange Handler="App.btnRemoveEmployee.setDisabled(!selected.length);" />
                </Listeners>
            </ext:GridPanel>
    
    
                     
           
    
                </Items>
            </ext:Viewport>
            
    
        </form>
    
    
    </body>
    </html>
     protected void Page_Load(object sender, EventArgs e)
            {
                if (!X.IsAjaxRequest)
                {
                    
                }
            }
    
         
            [DirectMethod]
            public void BindGridPanel()
            {
    
    
                Store1.DataSource = new List<object>
                {
                    new {
                        Name = "Bill Foot",
                        Email = "bill.foot@ext.net",
                        Start = new DateTime(2007, 2, 5),
                        Salary = 37000,
                        Active = true
                    },
                    new {
                        Name = "Bill Little",
                        Email = "bill.little@ext.net",
                        Start = new DateTime(2009, 6, 13),
                        Salary = 53000,
                        Active = true
                    },
                    new {
                        Name = "Bob Jones",
                        Email = "bob.jones@ext.net",
                        Start = new DateTime(2008, 10, 6),
                        Salary = 70000,
                        Active = true
                    },
                    new {
                        Name = "Bob Train",
                        Email = "bob.train@ext.net",
                        Start = new DateTime(2009, 5, 5),
                        Salary = 68000,
                        Active = true
                    },
                    new {
                        Name = "Chris Johnson",
                        Email = "chris.johnson@ext.net",
                        Start = new DateTime(2009, 1, 25),
                        Salary = 47000,
                        Active = true
                    },
                     new {
                        Name = "Bill Foot",
                        Email = "bill.foot@ext.net",
                        Start = new DateTime(2007, 2, 5),
                        Salary = 37000,
                        Active = true
                    },
                    new {
                        Name = "Bill Little",
                        Email = "bill.little@ext.net",
                        Start = new DateTime(2009, 6, 13),
                        Salary = 53000,
                        Active = true
                    },
                    
                };
                Store1.DataBind();
                GridPanel1.Render();
            }
    Attached Thumbnails Click image for larger version. 

Name:	Capture.PNG 
Views:	48 
Size:	34.8 KB 
ID:	24969   Click image for larger version. 

Name:	Untitled.png 
Views:	41 
Size:	31.6 KB 
ID:	24970  
    Last edited by fabricio.murta; Jun 02, 2017 at 10:28 AM.
  2. #2
    Hello again, Geovision!

    After this test case I finally forced the theme to be Gray and then I could see your issue. It seems this issue does not happen at all if you use Ext.NET default theme, Triton but that's -- nevertheless -- an issue that should be addressed. Seems all or most other themes suffer from the scroll reset on edit issue.

    You are probably overriding defaults in your project file, I'd strongly advise you to use a clean project when building test cases as it would have -- for example -- required you to specify Theme="Gray" in resource manager and we would have found earlier some of the issues were related to the theme while trying to reproduce your test cases.

    What happens now, is that we don't really want to go back to the beginning of the scroll when adding a record, but now must keep the scroll position intact. We'll see what's happening and come back to you soon!
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Hello @Geovision!

    After some trimming down and simplifying of your example, I finally could find that anything making the panel to refresh was moving the scrollbar over. And that was caused by the second render your code behind call does. Is there a special reason you needed to call that? The grid panel's view is refreshed automatically as you bind new data to the store, and re-rendering the whole component seems a little too overkill an operation after a view refresh.

    That said, check your own test case just by removing line 69 of your code behind code.

    Please consider simplifying the test cases you provide us as it took a lot of time to find that needle when just this was necessary to reproduce the issue:

    <%@ Page Language="C#" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        [DirectMethod]
        public void BindGridPanel()
        {
            var data = new List<object>();
    
            for (var i = 1; i <= 50; i++)
            {
                data.Add(new
                {
                    Name = "Name " + i.ToString(),
                    Email = "mail" + i.ToString() + "@ext.net",
                    Start = DateTime.Now.AddDays(i * (-1)).AddMonths(i * (-1)),
                    Salary = 1234 * ( (i%6) + 1 ),
                    Active = (i%7 == 0) ? true : false
                });
            };
    
            Store1.DataSource = data;
            Store1.DataBind();
    
            // This will re-render the already rendered grid panel and lose its scrolling state on next layout refresh..
            //GridPanel1.Render();
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title></title>
    
        <style>
            .x-column-header {
                font: bold 14px 'Tahoma',Times, serif !important;
                text-align: center !important;
                vertical-align: middle !important;
                height: 38px;
            }
    
            .x-column-header-inner .x-column-header-text {
                white-space: nowrap;
            }
        </style>
    
        <script>
            var addEmployee = function () {
                var grid = App.GridPanel1,
                    store = grid.getStore();
    
                store.insert(0, {
                    name: 'New Guy',
                    email: 'new@ext.net',
                    start: Ext.Date.clearTime(new Date()),
                    salary: 50000,
                    active: true
                });
            };
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" ID="ResourceManager1" Theme="Gray">
                <Listeners>
                    <DocumentReady Handler="App.direct.BindGridPanel();" />
                </Listeners>
            </ext:ResourceManager>
            <ext:Viewport ID="VP1" runat="server" RTL="true" Layout="FitLayout">
                <Items>
                    <ext:GridPanel ID="GridPanel1" runat="server">
                        <Store>
                            <ext:Store ID="Store1" runat="server">
                                <Model>
                                    <ext:Model runat="server">
                                        <Fields>
                                            <ext:ModelField Name="name" ServerMapping="Name" Type="String" />
                                            <ext:ModelField Name="email" ServerMapping="Email" Type="String" />
                                            <ext:ModelField Name="start" ServerMapping="Start" Type="Date" />
                                            <ext:ModelField Name="salary" ServerMapping="Salary" Type="Float" />
                                            <ext:ModelField Name="active" ServerMapping="Active" Type="Boolean" />
                                        </Fields>
                                    </ext:Model>
                                </Model>
                            </ext:Store>
                        </Store>
                        <TopBar>
                            <ext:Toolbar runat="server">
                                <Items>
                                    <ext:Button runat="server" Text="Add Employee" Icon="UserAdd" OnClientClick="addEmployee();" />
                                </Items>
                            </ext:Toolbar>
                        </TopBar>
                        <ColumnModel>
                            <Columns>
                                <ext:RowNumbererColumn runat="server" Width="50" />
                                <ext:Column runat="server" Text="Name" DataIndex="name" MinWidth="400" />
                                <ext:Column runat="server" Text="Email" DataIndex="email" Width="400" />
                                <ext:DateColumn runat="server" Text="Start Date" DataIndex="start" Format="MM/dd/yyyy" Width="400">
                                </ext:DateColumn>
                                <ext:NumberColumn runat="server" Text="Salary" DataIndex="salary" Format="$0,0" Align="Center" Width="400" />
                                <ext:CheckColumn runat="server" Text="Active?" DataIndex="active" Width="500" />
                            </Columns>
                        </ColumnModel>
                    </ext:GridPanel>
                </Items>
            </ext:Viewport>
        </form>
    </body>
    </html>
    No rowEditing, nor delete button, nor filters were related to the issue at all and just distracted us. Anyway, let us know if this approach is suitable for you or if you had a reason to do that Render() call commented out on my version's line 26.
    Fabrício Murta
    Developer & Support Expert
  4. #4
    Hello again @Geovision!

    Sorry, the code provided above is completely off! Please disregard it. It works simply because I've removed the grid view specifying it was RTL. So what we get there is no scrollbar reset, yes, but also the grid header scrolls to the opposite direction of the grid's view when you pull the scrollbar around.

    Notwithstanding, we've dug down the problem, and it turns to be the same as reported in this already opened bug thread: horizontale scroll bar always left when RTL is true (Chrome Only).

    Please follow the other thread. We'll close this one, but we are going to update the pointed thread real soon, as soon as we push the fix to GitHub!
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. Replies: 11
    Last Post: Jan 13, 2017, 1:27 AM
  2. Replies: 1
    Last Post: Apr 28, 2016, 5:49 PM
  3. Replies: 8
    Last Post: Jun 06, 2013, 12:42 PM
  4. MenuPanel - Horizontal Scroll
    By rsaldanhabr in forum 1.x Help
    Replies: 1
    Last Post: Aug 05, 2011, 2:45 PM
  5. Listview horizontal scroll bar
    By wh0urdady in forum 1.x Help
    Replies: 1
    Last Post: Jun 23, 2010, 10:41 PM

Posting Permissions