jqgrid json阅读器,用于arcgis服务器查询结果 [英] jqgrid json reader for arcgis server query results

查看:136
本文介绍了jqgrid json阅读器,用于arcgis服务器查询结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要哪种类型的json阅读器来绘制类似解决方案

您对jsonReader有疑问,也有其他疑问.在当前情况下,您可以使用

 jsonReader: {
    root: 'features',
    repeatitems: false
}
 

读取数据. 演示显示了结果如何:

更新:据我了解,您真正想要做的是调用一些 external URL,该URL为您提供JSON.由于安全原因,无法对另一台服务器执行标准Ajax请求(请参见同一来源策略 ).幸运的是,服务器sampleserver1.arcgisonline.com/ArcGIS支持JSONP请求.因此,要使用外部数据填充网格,可以使用以下代码

 $('#grid').jqGrid({
    url: 'http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/4/query',
    datatype: 'jsonp',
    postData: $.param({
        where: "1=1",
        returnGeometry: false,
        outFields: "ObjectID,NAME,STATE_NAME,CNTY_FIPS",
        f: "json"
    }),
    colModel: [
        {name: 'ObjectID', label: 'ID', width: 60, jsonmap: 'attributes.ObjectID'},
        {name: 'NAME', label: 'Name', width: 150, jsonmap: 'attributes.NAME'},
        {name: 'STATE_NAME', label: 'State', width: 120, jsonmap: 'attributes.STATE_NAME'},
        {name: 'CNTY_FIPS', label: 'FIPS', width: 60, jsonmap: 'attributes.CNTY_FIPS'}
    ],
    toppager: true,
    jsonReader: {
        root: 'features',
        repeatitems: false
    },
    loadonce: true,
    ignoreCase: true,
    height: 'auto'
});
 

此处中查看新演示.

更新2 :要能够使用本地搜索/过滤功能,请修改以上代码.最好将上面看到的postData替换为以下参数

ajaxGridOptions: { cache: true },
prmNames: {search: null, nd: null, sort: null, rows: null, order: null, page: null},
postData: {
    where: "1=1",
    returnGeometry: false,
    outFields: "ObjectID,NAME,STATE_NAME,CNTY_FIPS",
    f: "json"
}

请参见 filterToolbar所在的相应演示. /p>

what kind of json reader I need to plot data like these in a jqgrid?

Thanks!

解决方案

You have strange questions and all about the jsonReader. In the current case you can use

jsonReader: {
    root: 'features',
    repeatitems: false
}

to read the data. The demo shows how the results can looks like:

UPDATED: How I understand, what you want really to do is to call some external URL which provide you back the JSON. Standard Ajax request can't be done to another server because of security reasons (see same origin policy). Fortunately the server sampleserver1.arcgisonline.com/ArcGIS supports JSONP requests. So to fill the grid with external data you can use the following code

$('#grid').jqGrid({
    url: 'http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/4/query',
    datatype: 'jsonp',
    postData: $.param({
        where: "1=1",
        returnGeometry: false,
        outFields: "ObjectID,NAME,STATE_NAME,CNTY_FIPS",
        f: "json"
    }),
    colModel: [
        {name: 'ObjectID', label: 'ID', width: 60, jsonmap: 'attributes.ObjectID'},
        {name: 'NAME', label: 'Name', width: 150, jsonmap: 'attributes.NAME'},
        {name: 'STATE_NAME', label: 'State', width: 120, jsonmap: 'attributes.STATE_NAME'},
        {name: 'CNTY_FIPS', label: 'FIPS', width: 60, jsonmap: 'attributes.CNTY_FIPS'}
    ],
    toppager: true,
    jsonReader: {
        root: 'features',
        repeatitems: false
    },
    loadonce: true,
    ignoreCase: true,
    height: 'auto'
});

See the new demo here.

UPDATED 2: To be able to use local searching/filtering one should modify the above code. It's better to replace postData which one sees above to the following parameters

ajaxGridOptions: { cache: true },
prmNames: {search: null, nd: null, sort: null, rows: null, order: null, page: null},
postData: {
    where: "1=1",
    returnGeometry: false,
    outFields: "ObjectID,NAME,STATE_NAME,CNTY_FIPS",
    f: "json"
}

See the corresponding demo where filterToolbar works.

这篇关于jqgrid json阅读器,用于arcgis服务器查询结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆