beginBatch(bIgnoreError: Boolean);
bIgnoreError. Indicates if errors are ignored when requests are sent to server in batch mode. If this parameter is set to true, request transfer errors are ignored, otherwise they are not ignored.
The beginBatch method enables batch mode of sending requests to server.
After this method is called, the requests are sent not straight away, but after executing the RdsService.endBatch method.
To execute this example, the page must contain the DictionaryBox component named dictionaryBox (see Example of creating the DictionaryBox component ). Load all dictionary elements, determine their number, name and code:
// Get MDM dictionary
var source = dictionaryBox.getSource()[0];
// Get service for working with the dictionary
var service = source.getPPService();
var childs; // Dictionary children relative to the root
// Enable batch mode of request sending
if (!service.getIsBatchMode()) {
service.beginBatch();
// Callback function for the getChildEls method
var onChildLoaded = function (sender, args) {
var response = JSON.parse(args.ResponseText);
source.setTotalsCount(response.GetRdsElementsResult.totalCount, false);
};
// Callback function for the endBatch method
var onElemsLoaded = function (sender, args) {
console.log("Total number of dictionary elements: %s",
source.getTotalsCount(false));
var response = JSON.parse(args.ResponseText);
childs = response.BatchExecResult.its.it[0].GetRdsElementsResult.els.e;
for (var i = 0; i < childs.length; i++) {
console.log("Child element name: %s, code: %s", childs[i].n, childs[i].k);
var elemement = source.getElem(childs[i].k);
elemement.parseFromMd(childs[i], true);
};
source.setChildEls("", childs || [], false);
service.ChildLoaded.fire(this, {
Dictionary: source,
ParentKey: ""
});
};
var childs = service.getChildEls(source, "", PP.Delegate(onChildLoaded, this));
console.log(childs);
// Disable batch mode of request sending
service.endBatch(true, PP.Delegate(onElemsLoaded, this));
};
After executing the example all dictionary elements are loaded. The browser console shows total number of elements, name and code:
Total number of dictionary elements: 4
Child element name: Decade, code: 2083
Child element name: Man-day, code: 2084
Child element name: Second, code: 2085
See also: