Oct 15, 2013, 8:54 AM
[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???
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
.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
This works and displays the filters correctly
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]