<< Click to Display Table of Contents >>

SuperGIS Server JavaScript API

 

new sg.controls.AttributeInspector(options)

 

 

Description

建立屬性編輯工具

 

Parameters

 

Parameter

Type

Description

options

Object

(optional) 控制項

set object

Name

Type

Description

layerInfos

Object

(optional) 圖層資訊

Name

Type

Description

editable

Boolean

(optional) 設定是否允許編輯某圖層

featureLayer

sg.layers.GraphicsLater

(optional) 指定圖徵圖層

fieldInfos

Array.<object>

(optional) 指定欄位資訊

fieldInfos[].fieldName

String

(optional) 指定欄位名稱

fieldInfos[].editable

Boolean

(optional) 設定是否允許編輯某欄位

 

 

Methods

 

Methods

Type

Description

destroy()

none

移除控制項

first()

none

移至所選取的第一筆圖徵

hide()

none

隱藏控制項

last()

none

移至所選取的最後一筆圖徵

next()

none

移至所選取的下一筆圖徵

previous()

none

移至所選取的上一筆圖徵

show()

none

顯示控制項

startup()

none

初始化控制項

 

Events

 

Event

Description

attribute-change

屬性改變

delete

圖徵刪除

next

改變目標圖徵

 

 

Example

 

 

<script type="text/javascript" src="scripts/AttributeInspector.js"></script>

 

//Create AttributeInspector.

var ai = new sg.controls.AttributeInspector({

   layerInfos: {

         featureLayer: featureLayer,

         fieldInfos: [{

               fieldName: "Id",

               editable : false

         }],

         editable : true

   }

});

 

//Set feature attribute.

ai.on("attribute-change", function (e) {

e.feature.attributes[e.fieldName] = e.fieldValue;

});

 

//Delete feature when delete button are clicked.

ai.on("delete", function (e) {

  featureLayer.applyEdit(null, null, [e.feature]);

});

 

//Add save button on the AttributeInspector,before deleteButton.

var saveBtn = document.createElement("button");

saveBtn.innerHTML = "Save";

ai.deleteButton.parentNode.insertBefore(saveBtn, ai.deleteButton);

 

//Edit feature attribute when save button clicked.

AttachEvent(saveBtn, "click", function () {

   console.log("Save");

  var features = featureLayer.getSelectedFeatures();

        featureLayer.applyEdit(null, features, null);

   });

 

//Append AttributeInspector to infowindow

map.infoWindow.setContent(ai.node);

map.infoWindow.resize(300, 240);

 

 


©2015 Supergeo Technologies Inc.