Description
Sets the value of the key using the data from a DataWindow control, DataStore object, or DataWindowChild object.
Applies to
Syntax
objectname.SetValueByDataWindow ( string Key, dwcontrol DWControl {, boolean format } )
objectname.SetValueByDataWindow ( string Key, dwcontrol DWControl {, DWBuffer dwbuffer }, boolean changedonly, boolean format )
objectname.SetValueByDataWindow ( string Key, dwcontrol DWControl, boolean primarydata, boolean filterdata, boolean deletedata, boolean dwcdata {, boolean format } )
objectname.SetValueByDataWindow ( string Key, dwcontrol DWControl, DWBuffer dwbuffer {, long startrow {, long endrow {, long startcolumn {, long endcolumn } } } } {, boolean format } )
Argument |
Description |
---|---|
objectname |
The name of the JSONPackage object |
Key |
A string specifying the key name. |
dwcontrol |
A reference to a DataWindow control, DataStore, or DataWindowChild. |
dwbuffer |
A value of the dwBuffer enumerated datatype identifying the DataWindow buffer from which you want to get the data. For a list of valid values, see the section called “DWBuffer” in DataWindow Reference. If not specified, all of the DataWindow buffers will be obtained, however, the data for DataWindowChild will not be obtained (even if changedonly is false). |
changedonly |
A boolean specifying the changing flag.
|
primarydata |
A boolean specifying whether to get the data from the primary buffer.
|
filterdata |
A boolean specifying whether to get the data from the filter buffer.
|
deletedata |
A boolean specifying whether to get the data from the delete buffer.
|
dwcdata |
A boolean specifying whether to get the DataWindowChild data.
|
startrow (optional) |
The number of the first detail row in the buffer that you want to get. The default is 1. If it is 0 or negative, 1 is used. |
endrow (optional) |
The number of the last detail row in the buffer that you want to get. The default is the rest of the rows. If it is 0 or negative, it indicates the rest of rows. |
startcolumn (optional) |
The number of the first column in the buffer that you want to get. The default is 1. If it is 0 or negative, 1 is used. |
endcolumn (optional) |
The number of the last column in the buffer that you want to get. The default is the rest of the columns. If it is 0 or negative, it indicates the rest of columns. |
format |
A boolean specifying the JSON format.
See the section called “Supported JSON formats” in Application Techniques for details about the JSON format. |
Return value
Long. Returns 1 if it succeeds and -1 if an error occurs. If any argument's value is null, the method returns null.
Example 1
This example exports data from the DataWindow to the JSONPackage object.
// Integer SetValueByDataWindow (string Key, dwcontrol DWControl {, boolean format}) String ls_Dept_id_100 Restclient lrc_Dept JsonPackage ljpk_Dept ljpk_Dept = Create JsonPackage lrc_Dept = Create RestClient // The DataWindow column name and type must match with that of the JSON string returned from https://demo.appeon.com/PB/webapi_client/department dw_Dept.DataObject = "d_example_dept" lrc_Dept.Retrieve( dw_Dept, "https://demo.appeon.com/PB/webapi_client/department" ) // Gets data via RestClient dw_Dept.SetFilter( "dept_id = 100" ) // Filters the data that will be exported to the JSON string dw_Dept.Filter() // Exports the data from DataWindow to JSONPackage as a plain JSON string ljpk_Dept.SetValueByDataWindow("dept_id_100", dw_Dept, False) ls_Dept_id_100 = ljpk_Dept.GetJsonString() // Exports the data from JSONPackage at the string format // Prints ls_Dept_id_100 = {"dept_id_100":[{"dept_id":100, "dept_name":"R & D8", "dept_head_id":105}]}
Example 2
This example exports the modified data from the DataWindow to the JSONPackage object.
// Integer SetValueByDataWindow (string Key, dwcontrol DWControl {, DWBuffer dwbuffer}, boolean changedonly, boolean format) String ls_Dept_ModifyRow Restclient lrc_Dept JsonPackage ljpk_Dept ljpk_Dept = Create JsonPackage lrc_Dept = Create RestClient // The DataWindow column name and type must match with that of the JSON string returned from https://demo.appeon.com/PB/webapi_client/department dw_Dept.DataObject = "d_example_dept" lrc_Dept.Retrieve( dw_Dept, "https://demo.appeon.com/PB/webapi_client/department" ) // Gets data via RestClient // Modifies the DataWindow data If dw_Dept.RowCount() > 0 Then dw_Dept.SetItem(1, 2, "TestJsonPackage") End If // Exports the modified data from DataWindow to JSONPackage as a plain JSON string ljpk_Dept.SetValueByDataWindow("Dept_ModifyRow", dw_Dept, Primary!, TRUE, FALSE) ls_Dept_ModifyRow = ljpk_Dept.GetJsonString() // Exports the data from JSONPackage at the string format // Prints ls_Dept_ModifyRow = {"Dept_ModifyRow":[{"dept_id":100, "dept_name":"TestJsonPackage", "dept_head_id":105}]}
Example 3
This example exports the data from the specified DataWindow row and column to the JSONPackage object.
// Integer SetValueByDataWindow (string Key, dwcontrol DWControl, DWBuffer dwbuffer {, long startrow {, long endrow {, long startcolumn {, long endcolumn } } } } {, boolean format }) String ls_Dept_Row_Column Integer li_Return Restclient lrc_Dept JsonPackage ljpk_Dept ljpk_Dept = Create JsonPackage lrc_Dept = Create RestClient // The DataWindow column name and type must match with that of the JSON string returned from https://demo.appeon.com/PB/webapi_client/department dw_Dept.DataObject = "d_example_dept" lrc_Dept.Retrieve( dw_Dept, "https://demo.appeon.com/PB/webapi_client/department" ) // Gets data via RestClient // Exports data in rows 1 through 3 and in column 2 li_Return = ljpk_Dept.SetValueByDataWindow ("Dept_Name", dw_Dept, Primary!, 1, 3, 2, 2, FALSE) If li_Return <> 1 Then // Prints the error message if SetValueByDataWindow failed End If ls_Dept_Row_Column = ljpk_Dept.GetJsonString() // Exports the data as a string // Prints ls_Dept_Row_Column={"Dept_Name":[{"dept_name":"R & D8"}, {"dept_name":"Sales"}, {"dept_name":"Finance"}]}
See also