View Full Version : [CLOSED] Convert JsonReader.Fields from Ext.NET v1.3 to V2.x

May 02, 2012, 4:33 PM

Could you tell me how to convert JsonReader.Fields to Ext.NET V2.x. Because

14.1 RecordField has been renamed to ModelField and must be defined in Model.

Reader .Fields has been removed.

Here is my code:

public GridPanel GetGridFromQE(string tableName)
var dbHelpers = new DataHelpers();

DataSet ds = dbHelpers.GetDataFromQueryEngine(tableName);
var dt = ds.Tables[0];

var reader = new JsonReader();

var store = new Store
ID = "Store1",
Reader = { reader }

var grid = new GridPanel
ID = tableName,
Height = 400,
Store = { store },
Title = tableName,
Frame = true

foreach (DataColumn column in dt.Columns)
//The problem is here: reader.Fields doesn't exist
reader.Fields.Add(column.ColumnName, MappingType(column.DataType));
grid.ColumnModel.Columns.Add(new Column { Text = column.ColumnName, DataIndex = column.ColumnName, Width = 200 });

store.DataSource = dt;

return grid;
private ModelFieldType MappingType(Type type)
if (type == typeof(string))
return ModelFieldType.String;
if (type == typeof(DateTime))
return ModelFieldType.Date;
if (type == typeof(int))
return ModelFieldType.Int;
if (type == typeof(double))
return ModelFieldType.Float;
if (type == typeof(bool))
return ModelFieldType.Boolean;

return ModelFieldType.Auto;

In version 2, Reader.Fields has been removed, so I don't know how to reuse this code in Ext.NET v2
Great thanks for your help

May 02, 2012, 8:33 PM

You should add ModelFields into Model.Fields, then that Model into Store.Model.


Store store = new Store();

store.Reader.Add(new JsonReader());

Model model = new Model();
model.Fields.Add(new ModelField("field1"));
model.Fields.Add(new ModelField("field2"));

May 03, 2012, 11:41 AM
It works now. Thanks for your help.

Mar 12, 2015, 8:27 AM
My apologies for reopening an old thread. I'm having the same problem. In my aspx file, I have the following code:

<ext:JsonReader IDProperty="Id">
<ext:RecordField Name="Field1" Type="Int" />
<ext:RecordField Name="Field2" Type="String" />

If I change the field to Modelfield it still does not work. Can you please hand hold me to resolve this issue. Since I'm new, your hand holding will go a long way.


Mar 12, 2015, 8:39 AM
Hi @srikanthn27,

it still does not work

Please clarify what is exactly happening.

Mar 12, 2015, 9:36 AM
Hello Danill,

Thank you for the reply. What I meant was, I changed from ReaderFields to ModelField and I get an error message saying

"Type 'Ext.Net.JsonReader' does not have a public property named 'Model'."

Below is my updated code:

<ext:JsonReader IDProperty="Id">
<ext:Model runat="server"
<ext:ModelField Name="field1" Type="Int" />
<ext:ModelField Name="field2" Type="String" />
Please pardon my code formatting as I typed them in a hurry :-)

Mar 12, 2015, 11:22 AM
Please edit the post wrapping the code in [CODE] tags.
Forum Guidelines For Posting New Topics (http://forums.ext.net/showthread.php?3440)