[CLOSED] 2.3.0 Ext.NET - (Dynamic) GridPanel and Filter

  1. #1

    [CLOSED] 2.3.0 Ext.NET - (Dynamic) GridPanel and Filter

    After creating a new project yesterday and coping a dynamic GridPanel control (which rendered but no filters) I found the new update broke the code.
    Using code peek I could not find "get_TraceWriter()" in the Newtonsoft.Json.JsonSerializerSettings class???

    [MissingMethodException: Method not found: 'Newtonsoft.Json.Serialization.ITraceWriter Newtonsoft.Json.JsonSerializerSettings.get_TraceWriter()'.]
    Ext.Net.JSON.get_CopyCurrentSettings() +0
    Ext.Net.JSON.Serialize(Object obj, IList1 converters, IContractResolver resolver) +59
    Ext.Net.JSON.Serialize(Object obj, IList1 converters) +44
    Ext.Net.TokenUtils.NormalizeRawToken(String script) +98
    Ext.Net.TokenUtils.ParseAndNormalize(String script, Control seed) +56
    Ext.Net.BaseControl.CallTemplate(ScriptPosition position, String template, String name, Object[] args) +392
    Ext.Net.BaseControl.Call(ScriptPosition mode, String name, Object[] args) +54
    Ext.Net.BaseControl.Call(String name, Object[] args) +50
    Ext.Net.GridFilters.AddFilter(GridFilter filter) +175
    PM> Install-Package Ext.NET
    
    Ext.NET 2.3.0 121 Friday, October 11 2013
    
    Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
    
    Dependencies
    Ext.NET.Utilities (≥ 2.3.0)
    Transformer.NET (≥ 2.1.1)
    Newtonsoft.Json (≥ 5.0.6)
    WebActivatorEx (≥ 2.0.3)
    This code previously worked BUT the filters DID not get rendered. Hence I created a fresh project FW4.5 to resolve it: using (C#) VS2012 + IIS7.

    The code that creates this failure is below. I am creating a GridFilter object and adding to a new GridFilters collection via the addFilter method.
    Interestingly; previously when loading the asp page the grid loaded (there were no filters) and when checking the console I found addFilter not defined error (as if the grid filter js script had not been loaded) - there were no load errors on resources. It appeared the method was called before the js fully loaded.

    NOTE: DataColumns is based on a DataTable; two properties ColumnName and DataType stored in class object for eneration
    Also tried, which failed: gridFilters.AddFilter(new StringFilter { DataIndex = "Test"});

    // Iterate the DataColumns object; create GridFilter based on type and add to GridFilter collection

    var gridFilters = new GridFilters{ID="GridFilter", Local = true};
                foreach (var gridFilter in DataColumns.Select(s => DataTableToGridFilter(s.DataType, s.ColumnName)))
                {
                    gridFilters.AddFilter(gridFilter); // <== Fails when calling this line; adding GridFilter object to Colelction
                }
    // Used to generate a Filter object based on DataTable column Type
    private static GridFilter DataTableToGridFilter(Type type, String dataIndex)
            {
                if (type == typeof(string)) { return new StringFilter { DataIndex = dataIndex}; }
                if (type == typeof(DateTime))
                {
                    var df = new DateFilter { DataIndex = dataIndex };
                    df.DatePickerOptions.TodayText = "Today";
                    df.DatePickerOptions.MaxDate = DateTime.Now;
                    df.MinDate = DateTime.Now.AddMonths(-3);
                    return df;
                }
                if (type == typeof(int) || type == typeof(double)) { return new NumericFilter { DataIndex = dataIndex }; }
                if (type == typeof(Boolean)) { return new BooleanFilter { DataIndex = dataIndex }; }
                return new StringFilter { DataIndex = dataIndex };
            }
    ==================================== Example Code to illustrate =================

    .Net 4.0 C#
    When this is run it works but does not when the filters are cleared and the recreated (produces the error above)

    Uncomment ManuallySetFilters(); to generate the error

    <%@ Page Language="C#"%>
    <script runat="server">
        
        protected void Page_Load(object sender, EventArgs e)
        {
            if (X.IsAjaxRequest) return;
    
            var store1 = GridPanel1.GetStore();
            store1.DataSource = GetData();
            store1.DataBind();
    
            //ManuallySetFilters(); //<== Uncomment to produce the error
        }
    
        public void ManuallySetFilters()
        {
            GridFilters1.ClearFilters();
            GridFilters1.AddFilter(new StringFilter { DataIndex = "company" });
            GridFilters1.AddFilter(new NumericFilter{ DataIndex = "id" });
        }
        
        public object[] GetData()
        {
            return new object[] {
                new object[] { "3m Co", 1},
                new object[] { "Alcoa Inc",2 },
                new object[] { "Altria Group Inc",3 },
                new object[] { "American Express Company",4 },
                new object[] { "American International Group, Inc.",5 },
                new object[] { "AT&T Inc.",6 },
                new object[] { "Boeing Co.",7 },
                new object[] { "Caterpillar Inc.",8 },
                new object[] { "Citigroup, Inc.",9 }
            };
        }
    
    </script>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
        <head runat="server">
            <title></title>
            <ext:ResourceManager ID="ResourceManager1" runat="server"></ext:ResourceManager>
        </head>
        <body>
        <form id="form1" runat="server">
        <div>
            <ext:GridPanel ID="GridPanel1" runat="server" Width="300" Height="300" Title="Test Filters">
                <Store>
                    <ext:Store ID="Store1" runat="server" PageSize="5" AutoLoad="True">
                        <Model>
                            <ext:Model ID="Model1" runat="server">
                                <Fields>
                                    <ext:ModelField Name="company" Type="String" SortType="AsText" />
                                    <ext:ModelField Name="id" Type="Int" SortType="AsInt" />
                                </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Store>
                    <ColumnModel runat="server">
                    <Columns>                   
                        <ext:Column runat="server" Text="Company" DataIndex="company"/>
                        <ext:Column runat="server" Text="id" DataIndex="id" />
                     </Columns>
                    </ColumnModel>
                <Features>
                    <ext:GridFilters runat="server" ID="GridFilters1" Local="true">
                        <Filters>
                            <ext:StringFilter DataIndex="company" />
                            <ext:NumericFilter DataIndex="id" />
                        </Filters>
                    </ext:GridFilters>
                </Features>
            </ext:GridPanel>
        </div>
        </form>
    </body>
    </html>
    ================= Solution ====================


    gridFilters.AddFilter(gridFilter);
    produced the error (also previously worked but did not display the filters, the update shows up the issue)

    This works and displays the filters correctly
    gridFilters.Filters.Add(gridFilter);
    Last edited by Daniil; Nov 08, 2013 at 3:57 AM. Reason: [CLOSED]
  2. #2
    Hi @NaRaine,

    Strange, I cannot reproduce it.

    Though, there is a problem with 2.3.0 which might be related. Here is a workaround.
    http://forums.ext.net/showthread.php...l=1#post119136

    If the problem persists, could you, please, provide a test case?

    As for the AddFilter method. It is supposed to be used with a DirectEvent/DirectMethod only. During Page_Load, please just populate a Filters collection.
    Last edited by Daniil; Oct 17, 2013 at 4:52 AM.
  3. #3
    The Json.NET exception is also discussed here.
    http://forums.ext.net/showthread.php?26878
  4. #4
    Quote Originally Posted by NaRaine View Post
    Hence I created a fresh project FW4.5 to resolve it: using (C#) VS2012 + IIS7.
    Please clarify what environment were you able to reproduce it with? OS, VS, .NET?
  5. #5
    Could you, please, try the following sample with your old installation which throws the Exception?

    We need it to narrow down the problem.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            JSON.Serialize("test", new JRawValueJsonConverter());
        }
    </script>
    
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
        </form>
    </body>
    </html>

Similar Threads

  1. [CLOSED] dynamic date filter not working
    By PriceRightHTML5team in forum 2.x Legacy Premium Help
    Replies: 9
    Last Post: Aug 08, 2013, 6:25 AM
  2. Replies: 7
    Last Post: Mar 12, 2013, 8:15 AM
  3. Replies: 2
    Last Post: May 01, 2012, 4:57 PM
  4. Replies: 2
    Last Post: Apr 12, 2012, 5:44 AM
  5. Replies: 0
    Last Post: Jun 21, 2011, 12:18 PM

Tags for this Thread

Posting Permissions