Namespace sap.ndc.BarcodeScannerModule: sap/ndc/BarcodeScanner
TODO: description
As BarcodeScanner
is a static class, a jQuery.sap.require("sap.ndc.BarcodeScanner");
statement must be explicitly executed before the class can be used. Example: *
jQuery.sap.require("sap.ndc.BarcodeScanner"); sap.ndc.BarcodeScanner.scan( function (oResult) { / * process scan result * / }, function (oError) { / * handle scan error * / }, function (oResult) { / * handle input dialog change * / } );
Since: 1.28.0.
available
' indicating whether or not the bar code scanner feature is available. It can be used to bind to the visible
property of UI controls which have to be hidden in case the feature is unavailable. {sap.ui.model.json.JSONModel} | A JSON model containing the 'available' property |
sap.ndc.BarcodeScanner.scan(fnSuccess, fnFail, fnLiveUpdate)
The bar code scanning is done asynchronously. When it is triggered, this function returns without waiting for the scanning process to finish. The applications have to provide callback functions to react to the events of a successful scanning, an error during scanning, and the live input on the dialog.
fnSuccess
is passed an object with text, format and cancelled properties. Text is the text representation of the bar code data, format is the type of the bar code detected, and cancelled is whether or not the user cancelled the scan. fnError
is given the error, fnLiveUpdate
is passed the new value entered in the dialog's input field. An example:
sap.ndc.BarcodeScanner.scan( function (mResult) { alert("We got a bar code\n" + "Result: " + mResult.text + "\n" + "Format: " + mResult.format + "\n" + "Cancelled: " + mResult.cancelled); }, function (Error) { alert("Scanning failed: " + Error); }, function (mParams) { alert("Value entered: " + mParams.newValue); } );
{function} | fnSuccess? | Function to be called when the scanning is done or cancelled |
{function} | fnFail? | Function to be called when the scanning is failed |
{function} | fnLiveUpdate? | Function to be called when value of the dialog's input is changed |