[FIXED] [#1295] [4.1.0] Grouping breaks when data is reloaded

  1. #1

    [FIXED] [#1295] [4.1.0] Grouping breaks when data is reloaded

    On the following sample proceed through the following steps:
    • Expand group Owner: raphael - Count: 8
    • Expand group Owner: saldanha - Count: 7
    • Press PagingToolbar's reload button
    • Collapse group Owner: raphael - Count: 8
    • Collapse group Owner: saldanha - Count: 7

    Notice that both groups have been "destroyed".

    Thanks in advance

    <!DOCTYPE html>
    <html>
    <head runat="server">
    </head>
    <body>
        <ext:ResourceManager Theme="Crisp" ScriptMode="Debug" runat="server" />
    
        <ext:GridPanel Title="Ext.Net" Width="700" Height="500" Region="Center" runat="server">
            <Features>
                <ext:Grouping runat="server" HideGroupedHeader="true" StartCollapsed="true" GroupHeaderTplString='{columnName}: {name} - Count: {rows.length}' />
            </Features>
            <Store>
                <ext:Store AutoLoad="true" RemoteSort="true" RemoteFilter="true" RemotePaging="true" GroupField="Owner" runat="server">
                    <Proxy>
                        <ext:AjaxProxy Url="~/Example/LoadFakeRecords/" SortParam="sort">
                            <Reader>
                                <ext:JsonReader RootProperty="data" />
                            </Reader>
                        </ext:AjaxProxy>
                    </Proxy>
                    <Model>
                        <ext:Model IDProperty="ID" runat="server">
                            <Fields>
                                <ext:ModelField Name="ID" Type="String" />
                                <ext:ModelField Name="Name" Type="String" />
                                <ext:ModelField Name="Owner" Type="String" />
                            </Fields>
                        </ext:Model>
                    </Model>
                    <Sorters>
                        <ext:DataSorter Property="Owner" Direction="ASC" />
                    </Sorters>
                </ext:Store>
            </Store>
            <ColumnModel runat="server">
                <Columns>
                    <ext:Column Text="ID" DataIndex="ID" runat="server" />
                    <ext:Column Text="Name" Flex="1" DataIndex="Name" runat="server" />
                    <ext:Column Text="Owner" DataIndex="Owner" runat="server" />
                </Columns>
            </ColumnModel>
            <BottomBar>
                <ext:PagingToolbar runat="server" />
            </BottomBar>
        </ext:GridPanel>
    </body>
    </html>
    namespace SandBox.Controllers
    {
        public class ExampleController : System.Web.Mvc.Controller
        {
            public ActionResult Index() => View();
    
            public StoreResult LoadFakeRecords(string sort)
            {
                List<Entity> lst = new List<Entity>();
    
                for (int index = 0; index < 15; index++)
                {
                    lst.Add(new Entity
                    {
                        ID = index,
                        Name = $"Name - {index}",
                        Owner = index % 2 == 0 ? "raphael" : "saldanha"
                    });
                }
    
                if (!string.IsNullOrWhiteSpace(sort))
                {
                    lst = Sort(lst, sort);
                }
    
                return new StoreResult(lst, lst.Count);
            }
    
            private List<Entity> Sort(List<Entity> lst, string sort)
            {
                DataSorter sortDefinition = DataSorter.From(sort).FirstOrDefault();
    
                var parameter = Expression.Parameter(typeof(Entity));
    
                Func<Entity, Object> function = Expression.Lambda<Func<Entity, IComparable>>(Expression.Convert(Expression.Property(parameter, sortDefinition.Property), typeof(IComparable)), parameter).Compile();
    
                if (sortDefinition.Direction == SortDirection.ASC)
                {
                    return lst.OrderBy(function).ToList();
                }
                else
                {
                    return lst.OrderByDescending(function).ToList();
                }
            }
        }
    
        public class Entity
        {
            public int ID { get; set; }
    
            public string Name { get; set; }
    
            public string Owner { get; set; }
        }
    }
    Last edited by RaphaelSaldanha; May 12, 2016 at 2:31 PM.
  2. #2
    Hello @Raphael!

    Can you provide full namespace path for the Expression you are using on your code (line 33 on your controller)?
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Hello @Raphael!
    Can you provide full namespace path for the Expression you are using on your code (line 33 on your controller)?
    System.Linq.Expressions

    You will need the following "using" to run the example:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Linq.Expressions;
    using System.Web.Mvc;
    using Ext.Net;
    using Ext.Net.MVC;
  4. #4
    Hello Raphael!

    Thanks for sharing this issue!.. It is always a little troublesome to set up the controller and review the paths, so I've just rewritten your test case as a simpler one-file code:

    <%@ Page Language="C#" %>
    
    <script runat="server">
        private object TestData
        {
            get
            {
                var lst = new List<object>();
    
                for (int index = 0; index < 15; index++)
                {
                    lst.Add(new object[]
                    {
                        index,
                        "Name - " + index,
                        index % 2 == 0 ? "raphael" : "saldanha"
                    });
                }
    
                return lst;
            }
        }
    </script>
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <title>GroupBreak on Ext.NET 4</title>
    </head>
    <body>
        <ext:ResourceManager Theme="Crisp" ScriptMode="Debug" runat="server" />
    
        <ext:GridPanel ID="gp1" Title="Ext.Net" Width="700" Height="500" Region="Center" runat="server">
            <Features>
                <ext:Grouping runat="server" HideGroupedHeader="true" StartCollapsed="true" GroupHeaderTplString='{columnName}: {name} - Count: {rows.length}' />
            </Features>
            <Store>
                <ext:Store ID="st1" AutoLoad="true" GroupField="Owner" Data="<%# TestData %>" runat="server">
                    <Model>
                        <ext:Model IDProperty="ID" runat="server">
                            <Fields>
                                <ext:ModelField Name="ID" Type="String" />
                                <ext:ModelField Name="Name" Type="String" />
                                <ext:ModelField Name="Owner" Type="String" />
                            </Fields>
                        </ext:Model>
                    </Model>
                </ext:Store>
            </Store>
            <ColumnModel runat="server">
                <Columns>
                    <ext:Column Text="ID" DataIndex="ID" runat="server" />
                    <ext:Column Text="Name" Flex="1" DataIndex="Name" runat="server" />
                    <ext:Column Text="Owner" DataIndex="Owner" runat="server" />
                </Columns>
            </ColumnModel>
            <BottomBar>
                <ext:PagingToolbar runat="server" />
            </BottomBar>
        </ext:GridPanel>
    </body>
    </html>
    I have also removed other code that seemed not necessary to reproduce the issue.

    If possible, and not MVC-specific, we'd love if you provided us simple test cases like that. Of course, we are grateful for the provided samples the way they are nonetheless! This would just avoid confusion. All the linq and expressions subsystem was just unnecessary to reproduce the issue, it seems. :)

    We've logged the issue as #1295 on github!

    Hope you understand, and thanks again!
    Fabrício Murta
    Developer & Support Expert
  5. #5
    Hope you understand, and thanks again!
    I understand and you are very welcome.

    FabrÃ*cio, have you forgotten to link this thread to GitHub one?
    Last edited by RaphaelSaldanha; Mar 28, 2016 at 9:54 PM.
  6. #6
    Yes!!! I forgotten! Thanks for the heads up!
    Fabrício Murta
    Developer & Support Expert
  7. #7
    This Sencha bug report appears to be the case.
    https://www.sencha.com/forum/showthread.php?303384


    I could not reproduce it with Ext.NET 4.1.0 (ExtJS 6.0.2).


    As for v3, it is going to be fixed there if we ever upgrade to ExtJS 5.1.3.

Similar Threads

  1. Remote Sort breaks Grid Grouping
    By RaphaelSaldanha in forum 3.x Help
    Replies: 2
    Last Post: Mar 22, 2016, 2:11 PM
  2. Replies: 1
    Last Post: Dec 19, 2015, 11:14 AM
  3. [CLOSED] TreePanel breaks when reloaded
    By RCN in forum 3.x Legacy Premium Help
    Replies: 2
    Last Post: Dec 17, 2015, 3:35 PM
  4. Replies: 3
    Last Post: Oct 16, 2015, 10:25 AM
  5. Replies: 0
    Last Post: Jul 27, 2015, 12:51 PM

Posting Permissions