问题描述
我需要什么样的 json 阅读器来绘制像 ).幸运的是,服务器 sampleserver1.arcgisonline.com/ArcGIS
支持 JSONP 请求.因此,要使用外部数据填充网格,您可以使用以下代码
$('#grid').jqGrid({url: 'http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/4/query',数据类型:'jsonp',后数据:$.param({其中:1=1",返回几何:假,outFields: "ObjectID,NAME,STATE_NAME,CNTY_FIPS",f: "json"}),颜色型号:[{名称:'ObjectID',标签:'ID',宽度:60,jsonmap:'attributes.ObjectID'},{name: 'NAME', label: 'Name', width: 150, jsonmap: 'attributes.NAME'},{name: 'STATE_NAME', label: 'State', width: 120, jsonmap: 'attributes.STATE_NAME'},{名称:'CNTY_FIPS',标签:'FIPS',宽度:60,jsonmap:'attributes.CNTY_FIPS'}],toppager:真的,jsonReader:{根:'功能',重复项:假},加载一次:真实,忽略大小写:真,高度:'自动'});
在此处查看新演示.
UPDATED 2:为了能够使用本地搜索/过滤,应该修改上面的代码.最好把上面看到的postData
替换成下面的参数
ajaxGridOptions: { cache: true },prmNames: {search: null, nd: null, sort: null, rows: null, order: null, page: null},发布数据: {其中:1=1",返回几何:假,outFields: "ObjectID,NAME,STATE_NAME,CNTY_FIPS",f: "json"}
参见相应的演示,其中filterToolbar代码>有效.
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.
这篇关于用于arcgis服务器查询结果的jqgrid json阅读器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!