PropertyEventMethodIndex
$p.data - 5.0_4.4547B.20211124.201933

Provides functions to control the DataCollection in general.
The user can get/set the data from/in multiple data objects at the same time and dynamically create data objects.

Type

engine

Property Summary

Event Summary

Method Summary

create( dataCollectionString , dataCollectionObject )
Dynamically creates dataList and dataMap.
get( type , dcOptions , returnOptions )
Gets multiple DataList and DataMap objects that meet the specified conditions.
getAllDataCollection( type )
Returns all DataCollection contained in the page.
getBroadcast( )
Gets the broadcasting status of the DataCollection.
getInfo( idArray )
Gets details of the DataCollection (attributes defined in the XML).
getOption( propertyName )
Gets the properties of the dataCollection object.
remove( dataCollectionID )
Deletes dataList, dataMap, and linkedDataList.
set( dataType , dataObject , idArray )
Sets the data of multiple DataList and DataMap objects at the same time.
setBroadcast( flag )
Sets the broadcasting status of all DataCollection. Mainly used to minimize page refreshes due to the changes in the DataCollection.
setOption( propertyName , propertyValue )
Sets the properties of the dataCollection object.

Property Detail

Event Detail

Method Detail

create( dataCollectionString , dataCollectionObject )
Dynamically creates dataList and dataMap. Two ways (XML and JSON) are available as shown below.
Parameter
nametyperequireddescription
dataCollectionStringStringYXML string of dataList and dataMap
dataCollectionObjectObjectYJSON object of dataList and dataMap
Sample
// Create a dataList (in XML string). var dcStr = '<w2:dataList id="dataList1" baseNode="vector" repeatNode="item" valueNode=""> '+ '<w2:columnInfo>'+ '<w2:column id="OrderID" dataType="text"></w2:column>'+ '<w2:column id="CustomerID" dataType="text"></w2:column>'+ '<w2:column id="EmployeeID" dataType="text"></w2:column>'+ '<w2:column id="OrderDate" dataType="text"></w2:column>'+ '</w2:columnInfo>'+ '</w2:dataList>'; $p.data.create(dcStr); // Create a dataMap (in XML string). var dcStr = '<w2:dataMap baseNode="map" id="dataMap1">' + '<w2:keyInfo>' + '<w2:key id="key1" name="name1" dataType="text"></w2:key>' + '<w2:key id="key2" name="name2" dataType="text"></w2:key>' + '</w2:keyInfo>' + '</w2:dataMap>';' $p.data.create(dcStr); // Create a dataList (as a JSON object). var option = { "id" : "dataList1", "type" : "dataList", "option" : { "baseNode": "list", "repeatNode": "map" }, "columnInfo" : [ { "id" : "Code", "name": "Code Group", "dataType" :"text" }, { "id" :"CodeName", "name" : "Code Name", "dataType" :"text" } ] }; $p.data.create( option ); // Create a dataMap (as a JSON object). var option = { "id":"dataMap1", "type":"dataMap", "option":{ "baseNode":"map" }, "keyInfo":[ { "id":"column1", "name":"column1", "dataType":"text" },{ "id":"column2", "name":"column2", "dataType":"text" } ] }; $p.data.create( option );
get( type , dcOptions , returnOptions )
Gets multiple DataList and DataMap objects that meet the specified conditions.
Return types include XML, ARRAY, and JSON.
Parameter
nametyperequireddescription
typeStringYReturn type JSON, XML, or ARRAY
dcOptionsArrayYAn array that contains DataCollection (DataMap/DataList) ID or a JSON object with search conditions.
returnOptionsJSONNJSON object containing options for the return object
Return
typedescription
JSON||XML||ArrayDataCollection object of the corresponding type
Sample
//DataCollection is as shown below. <w2:dataCollection> <w2:dataMap id="dataMap1" style="" valueAttribute=""> <w2:keyInfo> <w2:key id="name" name="이름" dataType="text"/> <w2:key id="addr" name="주소" dataType="text"/> </w2:keyInfo> </w2:dataMap> </w2:dataCollection> // Only ID is given. $p.data.get("JSON",["dataLMap1"]); // Single $p.data.get("JSON",["dataLMap1","dataList1"]); // Multiple // (Return Data Example - Single ) { "dataMap1": {"name":"WebSquare","addr":"Seoul"} } // DataCollection conditions are given (such as key or id.) $p.data.get("JSON",[{ key : "dl", id : "dataLMap1" }]); // (Return Example) {"dl" : {"name":"WebSquare" , "addr":"Seoul"} } // When mixed. $p.data.get("JSON",["dataMap1",{ key : "dl", id : "dataLMap1" }]); // returnOptions Example // When there is one DataCollection object to get and the singleMode (to remove the highest object or XML node) is to be applied, use returnOptions. $p.data.get("JSON",["dataLMap1"],{"singleMode":true}); // (Return Data Example) {"name":"WebSquare" , "addr":"Seoul"}
getAllDataCollection( type )
Returns all DataCollection information contained in the same page. Not include DataCollection in another area such as IFrame or Popup.
Parameter
nametyperequireddescription
typestringNType of the DataCollection to return. (ID or object itself)
Return
typedescription
ArrayAn array containing DataCollection ID, or containing the DataCollection object when the type is "object".
Sample
var ret = $p.data.getAllDataCollection(); // ret == ["dataList1", "dataList2"]; var ret = $p.data.getAllDataCollection("object"); // ret == [dataList1, dataList2];
getBroadcast( )
Gets the broadcasting status of the DataCollection.
Return
typedescription
booleanBroadcasting status
getInfo( idArray )
Gets details of the DataCollection (attributes defined in the XML).
Parameter
nametyperequireddescription
idArrayArrayNAn array that contains DataCollection (DataMap/DataList) ID If not specified, all dataCollection.
Return
typedescription
JSONJSON object containing attributes of each dataCollection in JSON format.
Sample
$p.data.getInfo(); // Returns information of all dataCollection objects. $p.data.getInfo(["dataList1","dataMap1"]); // Returns information of dataList1 and dataMap1.
getOption( propertyName )
Gets the property values of the dataCollection object.
Parameter
nametyperequireddescription
propertyNameStringYProperties of DataCollection
Return
typedescription
StringReturns the properties of the dataCollection.
Sample
//DataCollection is as shown below. <w2:dataCollection> <w2:dataMap id="dataMap1" style="" valueAttribute="value"> <w2:keyInfo> <w2:key id="name" name="이름" dataType="text"/> <w2:key id="addr" name="주소" dataType="text"/> </w2:keyInfo> </w2:dataMap> </w2:dataCollection> $p.data.dataList1.getOption( "valueAttribute" ); // (Return Example) "value"
remove( dataCollectionID )
Deletes DataList, DataMap, and LinkedDataList objects. When a DataList object is removed, the LinkedDataList object that binds the removed DataList will be also deleted.
Parameter
nametyperequireddescription
dataCollectionIDStringYdataCollection ID.
Sample
$p.data.remove("dataMap1");
set( dataType , dataObject , idArray )
Sets the data of multiple DataList and DataMap objects at the same time.
linkedDataList is not supported. (Set the linkedDataList in the dataList that is bound with.)
Parameter
nametyperequireddescription
dataTypeStringYData Types include XML, ARRAY, and JSON.
dataObjectJSON|| XML|| ARRAYYData object to set
idArrayArrayNAn array that contains DataCollection (DataMap/DataList) ID or a JSON object with search conditions. If not specified, data setting will be made based on the keys defined in the dataObject.
Sample
//DataCollection is as shown below. <w2:dataCollection> <w2:dataMap id="dataMap1" style="" valueAttribute=""> <w2:keyInfo> <w2:key id="name" name="이름" dataType="text"/> <w2:key id="addr" name="주소" dataType="text"/> </w2:keyInfo> </w2:dataMap> </w2:dataCollection> //JSON Type var tmpJSON = {"name":"WebSquare","addr":"Seoul"}; $p.data.set("JSON" , {"dataMap1": tmpJSON } , ["dataMap1"] ); $p.data.set("JSON" , {"dataMap1" : tmpJSON } ); //XML Type var tmpXML = WebSquare.xml.parse( '<map><map id="dataMap1"><name>WebSquare</name><addr>Seoul</addr></map></map>' ); // Create an XML object. $p.data.set("XML" , tmpXML , ["dataMap1"] ); $p.data.set("XML" , tmpXML ); //ARRAY Type var tmpArray = ["WebSquare","Jeju"]; $p.data.set("ARRAY" , {"dataMap1":tmpArr} , ["dataMap1"]); $p.data.set("ARRAY" , {"dataMap1":tmpArr} );
setBroadcast( flag )
Sets the broadcasting status of all DataCollection. Mainly used to minimize page refreshes due to the changes in the DataCollection.
When the broadcasting is not enabled (false), the UI will not be refreshed even changes are made in the DataCollection.
When the broadcasting is turned on, the changes in the DataCollection will be automatically refelected on the UI.
Parameter
nametyperequireddescription
flagbooleanYBroadcasting status. True is to turn on the broadcasting and to reflect changes in the DataCollection on the UI, and false is to turn off the broadcasting.
Sample
// The following example is to maximize the speed of insertRow. $p.data.setBroadcast(false); for(var i = 0; i &lt; 10; i++){dataList1.insertRow(i)}; // Changes in the DataList will not be immediately reflected on the DataList. for(var i = 0; i &lt; 10; i++){dataList2.insertRow(i)}; $p.data.setBroadcast(true); // The UI components bound with dataList1 and dataList2 are updated upon broadcasting only.
setOption( propertyName , propertyValue )
Sets the properties of the dataCollection object (not including user-defined properties and ID.)
Parameter
nametyperequireddescription
propertyNameStringYName of the property to set.
propertyValueStringYProperty value to set.
Sample
// Not applied when the propertyName is not defined in the engine. (For example, ID and the user-defined properties.) $p.data.dataList1.setOption( "valueAttribute" , "value" );