在网上找了很多例子,在Arcgis server的开发中,关于identify查询绑定字段,都写的比较模糊,虽然查出了结果,但是显示的字段却仅限那几个layerid、layername和value,很难满足需要,显示效果也不好,后来通过自己亲测,发现是数据源绑定的问题。
之前的案例绑定的数据源都是:“datalist.dataProvider=identifyTask.executeLastResult;”
将其结果属性打印出来,会发现
........
accessibilityProperties = (mx.accessibility::UIComponentAccProps)#2
description = ""
forceSimple = false
name = ""
noAutoLabeling = false
shortcut = ""
silent = false
accessibilityShortcut = ""
activeEffects = (Array)#3
alpha = 1
attributes = (Object)#4
FID = "14"
name = "怒江傈僳族自治州"
Shape = "Polygon"
WRLD30_ID = "87"
automationDelegate = (null)
automationEnabled = true
automationName = ""
automationOwner = (com.esri.ags.layers::GraphicsLayer)#5
accessibilityDescription = ""
accessibilityEnabled = true
.........
validationSubField = (null)
verticalCenter = (null)
visible = true
width = 0
x = 422
y = 78.15
z = 0
layerId = 0
layerName = "world30"
value = "87"
..........
我们会发现,其实我们需要的字段在属性里,但是为什么却获取不到,后来我改变了绑定的数据源,将其改成:“datalist.dataProvider=lastIdentifyResultGraphic.attributes;”
然后就可以在表格中直接绑定其属性字段名称了。
<mx:DataGrid id="datalist" x="10" y="149" width="206" height="298">
<mx:columns>
<mx:DataGridColumn width="56" dataField="FID" headerText="序号"/>
<mx:DataGridColumn width="150" dataField="name" headerText="所选地名"/>
</mx:columns>
</mx:DataGrid>