I have a Ext.data.TreeStore which read data from text file :
this.store = Ext.create('Ext.data.TreeStore', {
model: "GeoExt.data.LayerTreeModel",
proxy: new Ext.data.HttpProxy({
url: 'data/test.json',
reader: {
type: 'json',
root: 'children',
idProperty: 'Id'
}
}),
folderSort: true
});
This is the file content:
[
{
text: "Category1",
leaf: false,
expanded: true,
checked: false,
children: [
{
text: "A1",
layer: "A2",
name: "A3",
leaf: true,
checked: false,
nodeType: "gx_layer"
},
{
text: "B1",
layer: "B2",
name: "B3",
leaf: true,
checked: false,
nodeType: "gx_layer"
}
],
nodeType: "gx_layer"
},
{
text: "Category2",
leaf: false,
expanded: true,
checked: false,
children: [
{
text: "C1",
layer: "C2",
name: "C3",
leaf: true,
checked: false,
nodeType: "gx_layer"
}],
nodeType: "gx_layer"
}
]
I've noticed in firebug that the get doesn't return JSON struct , but plain text. but it works.
I want to get the same result but getting the tree nodes from webservice (which brings it back from postgres).
The first simplest thing I tried was (also tried text/json):
[WebMethod]
public void GetJSON()
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ContentType = "text/plain";
HttpContext.Current.Response.Charset = "utf-8";
string res = File.ReadAllText(@"D:\test.json");
HttpContext.Current.Response.Write(res);
}
And I'm getting error :
Request format is unrecognized for URL unexpectedly ending in '/getJSON'.
which make sense because the file isn't JSON (but this is how I managed to make it work).
I would like help with 2 things :
- What is the correct JSON format I need to use to get the same result as I got in this example ?
- How do I serve the same data from webservice ?
Thank you !