Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a Ext.data.TreeStore which read data from text file :

enter image description here

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.

enter image description here

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 :

  1. What is the correct JSON format I need to use to get the same result as I got in this example ?
  2. How do I serve the same data from webservice ?

Thank you !

share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.