...
类型 | 对象 | 子对象 | 事件 |
---|---|---|---|
ClientSide | 左侧报表 | spreadsheetReport | onLinkClick |
宏代码
代码块 | ||||||
---|---|---|---|---|---|---|
| ||||||
function paramToString(v) {
return v == null ? null : v.toString();
}
function main(spreadsheetReport, ruleName, params, page, pageContext) {
//配置目标单元格(员工姓名扩展字段所在单元格)
var actionCell = "B3";
//配置右侧报表的节点Id
var targetResId = "I402882fd015b21fa21fa98e7015b220a522c00c0";
var newReport = false;
var dashlet = page.findDashletByReportId(targetResId);
if (!dashlet)
return;
var portlet = dashlet.currentPortlet;
if (!portlet) {
return;
}
//获取右侧报表电子表格对象
var actionReport = portlet.getPortletObject();
var list = actionReport.getExpandedPositions(actionCell);
//获取目标单元格
var cell = getInsCell(params, list, actionReport);
var doc = cell.ownerDocument;
var c = cell;
var top = -1;
var scale = doc._scale || 1;
var posScale = domutils.isMobile() ? 1 : scale;
while (c) {
top += c.offsetTop;
c = c.offsetParent;
}
var frozenColumn = doc.getElementById('frozenColumn');
var frozenTop = frozenColumn ? frozenColumn.clientHeight : 0;
var el;
if (domutils.isIE()) {
el = doc.documentElement;
} else {
el = doc.body;
}
var bodyWidth = doc.documentElement.clientWidth;
var bodyHeight = doc.documentElement.clientHeight;
if (doc.divScroll) {
doc.divScroll.scrollTop = (top + cell.clientHeight + 2) * posScale;
if (top - doc.divScroll.scrollTop / posScale < frozenTop) {
doc.divScroll.scrollTop = (top - frozenTop + 1) * posScale;
}
} else {
el.scrollTop = (top - 2 * cell.clientHeight + 2) * posScale;
if (top - el.scrollTop / posScale < frozenTop) {
el.scrollTop = (top - frozenTop + 1) * posScale;
}
}
//获取目标单元格
function getInsCell(params, list, actionReport) {
var cellLight;
for (var i = 0; i < list.length; i++) {
var pos = actionReport.parseCellIndex(list[i]);
var cell = actionReport.getCell(pos[0], pos[1]);
if (cell.bgColor) {
cell.bgColor = "";
}
//高亮目标单元格
if (cell.innerHTML == params[0][0]) {
cellLight = actionReport.getCell(pos[0], pos[1]);
cellLight.bgColor = "yellow";
}
}
return cellLight;
}
} |