-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathTATableData.js
More file actions
66 lines (62 loc) · 2.25 KB
/
TATableData.js
File metadata and controls
66 lines (62 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/**
* @class TATableData
* @classdesc Class to get Data from built table
*
* @constructs TATableData
* @param {Object} globals - object of global report variables {pageContext: this.pageContext, report: report, user: user, state: state, confirmit: confirmit, log: log}
* @param {String} tableName
*/
class TATableData{
private var _globals;
private var _tableName;
function TATableData(globals, tableName){
_globals = globals;
_tableName = tableName
}
/**
* @memberof TATableData
* @instance
* @function GetTableRowHeaders
* @description function to get rowheaders with ids
* @returns {Object} - object with ids, titles and row indexes
*/
function GetTableRowHeaders(){
var rowheaders={
length: 0
};
var rowHeaderTitles = _globals.report.TableUtils.GetRowHeaderCategoryTitles(_tableName);
var rowHeaderIds = _globals.report.TableUtils.GetRowHeaderCategoryIds(_tableName);
for(var i=0; i<rowHeaderIds.length;i++){
rowheaders[rowHeaderIds[i][0]+((rowHeaderIds[i].length>1)?("_block"+rowHeaderIds[i][1]):"")] = {title: rowHeaderTitles[i][0], index: i, categoryId: rowHeaderIds[i][0].toLowerCase(), blockId: ((rowHeaderIds[i].length>1)?("block"+rowHeaderIds[i][1]):null)};
rowheaders.length++;
}
return rowheaders;
}
/**
* @memberof TATableData
* @instance
* @function GetBlocks
* @description function to get parent rowheader ids
* @returns {String}
*/
function GetBlocks(){
var blocks = [];
var rowHeaderIds = _globals.report.TableUtils.GetRowHeaderCategoryIds(_tableName);
var blockExists = false;
if(rowHeaderIds.length >0 && rowHeaderIds[0].length > 1){
for(var i=0; i<rowHeaderIds.length; i++){
blockExists = false;
for(var j = 0; j < blocks.length; j++){
if( ("block"+rowHeaderIds[i][1]) == blocks[j]){
blockExists = true;
break;
}
}
if( !blockExists ){
blocks.push("block"+rowHeaderIds[i][1]);
}
}
}
return blocks
}
}