问题:pentaho ctools cde 插件BTable 对维度进行格式化,这个需求很少见,因为维度一般都是字符串,但遇到维度是浮点数值型的时候,就需要对维度进行格式化
修改BTable插件的代码如下:
BTable 使用的Table
%.2f
bt.table.js
191行代码,添加对维度值的类型colType设置
$.each(normalizedJson.metadata, function(i, v) { var colName = v.colName; if(colName.indexOf("]/[") > 0 || $.inArray(colName, measureQualifiedNames) >= 0) { v.colType = "numeric"; } else { if(colName != "[Measures].[MeasuresLevel]" && $.inArray(colName, dimensionQualifiedNames) < 0 && $.inArray(colName, pivotDimensionQualifiedNames) < 0) v.colType = "numeric"; else { if(v.colType === 'Numeric') v.colType = "numeric"; else v.colType = "string"; } } });
BTableComponent.js
579行插入如下代码,添加对维度值的格式colFormat设置
/* * Callback for when the table is finished drawing. Called every time there * is a redraw event (so not only updates, but also pagination and sorting). * We handle addIns and such things in here. */ fnDrawCallback: function(dataTableSettings) { var dataTable = dataTableSettings.oInstance, cd = this.chartDefinition, myself = this; this.timer.check("Table drawn without alarms and spans"); var measuresLevelColIdx = $.inArray("[Measures].[MeasuresLevel]", cd.colHeaders); var formatStrings = myself.bTable.olapCube.getFormatStrings(); var cellFormats = []; if(measuresLevelColIdx < 0) { $.each(myself.rawData.metadata, function(i, v) { if(v.colType == "numeric" && v.colName.indexOf("[Measures].[") >= 0) { if (!v.colIsCalculated) { var start_pos = v.colName.indexOf("[Measures]."); if(start_pos >= 0) { var end_pos = v.colName.indexOf("]", start_pos+10); var measureName = v.colName.substring(start_pos,end_pos+1); cellFormats.push(formatStrings[measureName]); } } else { cellFormats.push(v.colFormat); } } else { if(v.colType == "numeric" && v.colFormat !== undefined) { cellFormats.push(v.colFormat); } else { cellFormats.push(""); } } }); }
898行插入如下代码,添加对维度值的格式化
if(coltype == "numeric") { oRows.each(function(i, v) { var aData = oTable.fnGetData(this); var value = aData[index] == "" ? 0 : parseFloat(aData[index]); if (format && (typeof value != "undefined" && value !== null)) { $('td:eq(' + index + ')',this).text(bt.utils.getLocalizedFormattedValue(format,value)); } }); }
最后
在BTable 的 Post Fetch
function f(data) { // BTable/resources/amd-components/BTable/lib/bt.utils.js 389行 // case "": return valueString; // case "none": return valueString; // case "general number": formatString = "0.00"; break; // case "currency": formatString = "#,##0.00"; break; // case "fixed": formatString = "0,.00####"; break; // case "standard": formatString = "#,##0"; break; // case "percent": formatString = "0.00%"; break; // case "scientific": formatString = "0.00e+00"; break; // case "yes/no": return testZeroValue(valueString) ? "No" : "Yes"; // case "true/false": return testZeroValue(valueString) ? "False" : "True"; // case "on/off": return testZeroValue(valueString) ? "Off" : "On"; // data.metadata[3].colType = 'Numeric' // data.metadata[3].colFormat = 'Currency' data.metadata[7].colType = 'Numeric' data.metadata[7].colFormat = 'general number' return data; }
...
相关推荐
Learning Pentaho CTools Color Images Learning Pentaho CTools Color Images pentaho数据可视化 CTools 套件学习 使用书籍
Being an introductory chapter Chapter 1, Getting Started with CTools andChapter 9: Pentaho App Builder, Chapter 10, Embed, Deploy, and Debugdoes not contain code files. Chapter 1, Getting Started ...
learning-pentaho-ctoolslearning-pentaho-ctoolslearning-pentaho-ctoolslearning-pentaho-ctoolslearning-pentaho-ctoolslearning-pentaho-ctoolslearning-pentaho-ctools
Pentaho and CTools are two of the fastest and most rapidly growing tools for practical solutions not found in any other tool available on the market. Using Pentaho allows you to build a complete ...
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, ...
NULL 博文链接:https://qq85609655.iteye.com/blog/2331671
第9章,Pentaho App Builder,讨论了为Pentaho创建的一项新功能,即无需创建Java代码即可创建插件的功能。 第10章,嵌入,部署和调试,将说明如何将CDF和CDE仪表板都嵌入到第三方应用程序中。 ##相关的Apache产品...
Pentaho8.1.0.3和pentaho-cde源码在eclipse中的构建及调试,
BTable是Pentaho社区仪表板设计器(CDE)的组件,该组件扩展了具有OLAP功能的标准表组件,并提供了新的钻取体验。 仪表板用户可以通过上下文菜单轻松地与表格进行交互,该菜单允许:-添加,更改或删除维度-添加,...
GMapsOverlay 是 Pentaho CDE(社区仪表板编辑器)的插件,允许用户使用 Google Maps Overlays 创建自定义地图。
Pentaho社区仪表板设计器(CDE)的无处不在的组件。 视频教程及更多信息,请 。 BTable是根据。 该插件是使用。 有关安装的说明 关于BTable版本编号的注意事项: Pentaho 7.0使用较新版本的Spring平台。 这就是...
pentaho bi平台的dashboard组件 包括 pentaho-cdf-dd-13.09.10.zip pentaho-cdf-13.09.10.zip ...BTable-pentaho4-STABLE-1.5.zip cda-samples-13.09.10.zip pentaho-cdf-dd-solution-13.09.10.zip
1:Learning Pentaho CTools(PACKT,2016).pdf 2:Pentaho Data Integration Beginner's Guide, Second Edition.pdf 3:Packt.Pentaho for Big Data Analytics.2013.pdf 4:pentaho kettle solutions.pdf 5:[Packt ...
NULL 博文链接:https://qq85609655.iteye.com/blog/2372421
pentaho saiku插件
Pentaho的插件层 12 Pentaho的资源库系统 13 Solution 资源库 13 Runtime资源库 14 Content资源库 15 Audit资源库 16 Pentaho的运行机制 17 Pentaho平台的启动与终止 17 PentahoSession的管理 18 Pentaho平台的...
常春藤PDI MongoDB步骤 适用于MongoDB的Pentaho数据集成插件 编译 mvn clean install ## License该项目使用AGPLv3 支持 联系。
流元数据插件 Pentaho 数据集成插件,用于对流元数据进行采样
文件元数据插件一个Pentaho Data Integration插件,用于启用文件元数据扫描