Hi, we use the code attached below. The grid load method is called multiple times in a for-loop. In each iteration ...
Hi,
we use the code attached below. The grid load method is called multiple times in a for-loop. In each iteration we have an alert box popping up. If we click the ok buttons in the alerts slowly, all xml files from all loops are rendered in the grid.
But if we click the ok buttons in the alerts very fast, only some xml files of the loops are rendered in the grid.
What extra code do we have to implement, we need all xml files in one grid?
Thank you.
Regards, Marc
var theTaskGrid;
//general variables for action processor requests
var apUrl = "%%Name.String('webserverUrl')%%/TIBCOActProc/ActionProcessor.servlet?action=";
var apIProcessName = "PHBPPDEV01";
var apComputerName = "HEI-INT01";
var apIpAddress = "10.128.158.129";
var apTcpPort = "10010";
var apIsDirector = "true";
var apUserName = "imac01"; //%%User.Name()%%
// variables for taskListRequest
var taskIsReturnAllFields = "false";
var taskIsReturnAllCDQPs = "true";
var taskStartIndex = "0";
var taskReturnCount = "20";
var taskHold = "true";
function doInitGrid() {
theTaskGrid = new dhtmlXGridObject('myTaskGrid');
<!-- TaskGrid configuration -->
theTaskGrid.setImagePath("%%Name.String('webserverUrl')%%/%%Name.String('globalJavascripts')%%/dhtmlx/imgs/");
theTaskGrid.setHeader("Case Number,Step Name,Description,Arrived,Deadline,Workqueue");
theTaskGrid.attachHeader("#rspan,#select_filter,#rspan,#rspan,#rspan,#rspan");
theTaskGrid.setInitWidthsP("10,17,17,13,13,*");
theTaskGrid.setColAlign("right,left,left,right,right,left");
theTaskGrid.setColTypes("txt,ro,txt,ro,ro,txt");
theTaskGrid.setColSorting("int,str,str,date,date,str");
theTaskGrid.enableEditEvents(false,false,false);
theTaskGrid.setSkin("light");
theTaskGrid.attachEvent("onRowSelect",doOnRowSelected);
//theTaskGrid.enableAutoHeigth(true);
//theTaskGrid.enableAutoWidth(true);
theTaskGrid.init();
//defining the row level parser
theTaskGrid._process_custom_xml = function(xml) {
this._parsing=true;
// get all row elements from the XML
var rows = xml.doXPath("//sso:vWorkItem");
for (var i = 0; i < rows.length; i++) {
var id = this.getUID(); // the XML doesnt have native IDs, so we will generate custom ones
// store references to each row element
this.rowsBuffer[i] = {
idd: id,
data: rows[i],
_parser: this._process_custom_xml_row, // the cell parser method
_locator: this._get_custom_xml_data // the data locator method
};
// store ID reference
this.rowsAr[id]=rows[i];
}
// force the grid view update, after data loading
this.render_dataset();
this._parsing=false;
}
// define the cell level parser
theTaskGrid._process_custom_xml_row=function(r, xml) {
var aCaseNumber = this.xmlLoader.doXPath("./sso:CaseNumber", xml)[0];
var aStepName = this.xmlLoader.doXPath("./sso:StepName", xml)[0];
var aDescription = this.xmlLoader.doXPath("./sso:Description", xml)[0];
var aArrived = this.xmlLoader.doXPath("./sso:Arrived", xml)[0];
var aDeadline = this.xmlLoader.doXPath("./sso:Deadline", xml)[0];
// todo-9 theTaskGrid.setHeader( "...,Workqueue" );
var strAr = [
aCaseNumber.firstChild.data,
aStepName.firstChild.data,
aDescription.firstChild.data,
aArrived.firstChild.data.substr(0, 10),
aDeadline.firstChild.data.substr(0, 10),
""
];
// we don't need any custom attributes, so set just a plain array
r._attrs={};
for (j=0; j < r.childNodes.length; j++) {
r.childNodes[j]._attrs={};
}
//finish data loading
this._fillRow(r, strAr);
return r;
}
var workQsRequest= apUrl +
'<?xml version="1.0"?><ap:Action xmlns:ap="http://tibco.com/bpm/actionprocessor" xmlns:sso="http://tibco.com/bpm/sso/types">' +
'<ap:Authentication><ap:Login Id="login"><sso:NodeCtx><sso:NodeId>' +
'<sso:Name>' + apIProcessName +'</sso:Name>' +
'<sso:ComputerName>' + apComputerName + '</sso:ComputerName>' +
'<sso:IPAddress>' + apIpAddress + '</sso:IPAddress>' +
'<sso:TCPPort>' + apTcpPort + '</sso:TCPPort>' +
'<sso:IsDirector>' + apIsDirector + '</sso:IsDirector></sso:NodeId>' +
'<sso:UserName>' + apUserName + '</sso:UserName>' +
'<sso:Password></sso:Password>' +
'</sso:NodeCtx></ap:Login></ap:Authentication>' +
'<ap:User><ap:GetWorkQs Id="getWorkQs"/></ap:User></ap:Action>';
var workQsResponse = dhtmlxAjax.getSync(workQsRequest);
// get all workQTag elements from the XML
var workQTagArray = workQsResponse.doXPath("//sso:Tag");
for (var i = 0; i < workQTagArray.length; i++) {
var workQTag = workQTagArray[i].firstChild.data;
alert(workQTag);
var workItemsRequest = apUrl +
'<?xml version="1.0"?><ap:Action xmlns:ap="http://tibco.com/bpm/actionprocessor" xmlns:sso="http://tibco.com/bpm/sso/types">' +
'<ap:Authentication><ap:Login Id="login"><sso:NodeCtx><sso:NodeId>' +
'<sso:Name>' + apIProcessName +'</sso:Name>' +
'<sso:ComputerName>' + apComputerName + '</sso:ComputerName>' +
'<sso:IPAddress>' + apIpAddress + '</sso:IPAddress>' +
'<sso:TCPPort>' + apTcpPort + '</sso:TCPPort>' +
'<sso:IsDirector>' + apIsDirector + '</sso:IsDirector></sso:NodeId>' +
'<sso:UserName>' + apUserName + '</sso:UserName>' +
'<sso:Password></sso:Password>' +
'</sso:NodeCtx></ap:Login></ap:Authentication>' +
'<ap:WorkQ><ap:MakeWorkItemList Id="workItems\">' +
'<sso:WorkQTag>' + workQTag +'</sso:WorkQTag>' +
'<sso:WICriteria><sso:FilterExpression/><sso:SortFields/></sso:WICriteria><sso:WIContent>' +
'<sso:IsReturnAllFields>' + taskIsReturnAllFields + '</sso:IsReturnAllFields>' +
'<sso:CaseFieldNames/>' +
'<sso:IsReturnAllCDQPs>' + taskIsReturnAllCDQPs + '</sso:IsReturnAllCDQPs>' +
'<sso:CDQPNames/></sso:WIContent>' +
'<sso:StartIndex>' + taskStartIndex + '</sso:StartIndex>' +
'<sso:ReturnCount>' + taskReturnCount + '</sso:ReturnCount>' +
'<sso:Hold>' + taskHold + '</sso:Hold>' +
'</ap:MakeWorkItemList></ap:WorkQ></ap:Action>';
theTaskGrid.load(workItemsRequest, "custom_xml" );
}
} // function doInitGrid
a) the grid.parse and grid.load methods purposed to load all dataset at once, not items one by one
b) the behavior highly depends on the data in responses, but in any case the grid use single loading element for load command, so when you executing new loading command before old finished - old loading will be dropped in favor of new one. To resolve issue you can try to use
theTaskGrid.xmlLoader=new dtmlXMLLoaderObject(theTaskGrid.doLoadDetails, theTaskGrid, true, theTaskGrid.no_cashe);
theTaskGrid.load(workItemsRequest, "custom_xml" );
With such approach , new loader will be created before each request, so multiple load commands can be executed in the same time