I want to hide two of the crosstab columns based on some condition. I have been able to achieve it by using
function onPrepareCell( cell, reportContext )
if(some condition){
if( cell.getCellID() == cell#){
cell.getStyle().setDisplay("none");
}
}
in the onPrepare event of cross tab. It works fine in PDF,HTML format but the columns are not getting hidden when the format is Excel. I need to get this done soon please help
I got the answer from BIRT exchange i am posting the answer here so that it may be helpful to others
In the onPrepare() event of crosstab you can write the code as given below
function onPrepareCrosstab( crosstab, reportContext )
{
if(some condition ){
reportContext.getDesignHandle().getElementByID(ElementId#).setStringProperty("width","0px");
}
}
here ElementId# is the Id# of the cell you want to hide. As you can see we can also use this to change the width of the cell dymanically.
Try your code in an OnCreateCell event.
Related
I have a grid with several columns, most of which have values selectable from a given set. (i.e. they are shown as dropdown boxes when inserting/updating.) I want to enable filtering, but not necessarily on all columns at once. So I tried adding an empty option for each column, but this means it also shows up in the dropdown for insert/update, which is not what I want.
So how should I solve this? Do I need to override one or more of the row renderer functions?
You can redefine filterTemplate of the column like the following:
filterTemplate: function() {
var $select = jsGrid.fields.select.prototype.filterTemplate.call(this);
$select.prepend($("<option>").prop("value", "0").text("(All)"));
return $select;
}
Here is the working fiddle http://jsfiddle.net/tabalinas/g68ofLs1/
Is there any way i can hide HOT columns from javascript?
The requirement is such that the column to hide will come as a parameter in javascript and based on that the respective column will show hide accordingly.
The HOT has rowHeaders and colHeaders and the data with 20 columns.
Please advise.
OUTDATED SOLUTION
Ok I founnd a possible solution. I tested it out on my own system but it's actually quite simple.
You should be using a customRenderer in your columns option. Read up about this if you aren't already. The idea is that you're giving each cell its own renderer. In this custom function, you can do something like this:
var colsToHide = [3,4,6]; // hide the fourth, fifth, and seventh columns
function getCustomRenderer() {
return function(instance, td, row, col, prop, value, cellProperties) {
if (colsToHide.indexOf(col) > -1) {
td.hidden = true;
} else {
td.hidden = false;
}
}
}
What this renderer does is hide the cells that the var colsToHide specify. All you do now is add a DOM element that lets the user pick which and so every time the table gets rendered (which happens basically after any change, or manually triggered need be), the cells in the columns specified will be hidden, keeping the data array intact like you described. And when not in colsToHide they are re-rendered so make sure you get that working as well.
Here I implemented it with very basic functionality. Just enter the index of a column into the input fields and watch the magic happen.
http://jsfiddle.net/zekedroid/LkLkd405/2/
Better Solution: handsontable: hide some columns without changing data array/object
I wanted to identify which Slick editor is being used in the current selected Column. Is there anyway to do this?
Ok, I got.
We can use activeCell with columns to get the current select column. Then from the column.editor attribute, we cloud compare what is the editor currently select cell possess.
var column = columns[activeCell];
if(column.editor && column.editor === Slick.Editors.Text)
{
// Code with identification.
}
How can i set the with of crosstab cell from the events?
I tried doing
this.width="0in";
from onCreate() event but it does not work. I need help
If you're just trying to hide the cell, you might try something like this, in your crosstab script:
function onCreateCell( cellInst, reportContext )
{
if (cellInst.getCellID() == cellID#){
cellInst.getStyle().setDisplay("none");
}
}
Here's a link to the actual post that this comes from. It shows another option, for setting the actual width: http://www.birt-exchange.org/org/forum/index.php/topic/22736-dynamically-change-column-width-cross-tab/
I need to make a crosstab column visible or hidden based on a report parameter. How can it be done?
In the onPrepare event of crosstab you can do some thing like this
function onPrepareCell( cell, reportContext ){
if(reportContext.getParameterValue("reportParameter") == something ){
if( cell.getCellID() == cell#){
cell.getStyle().setDisplay("none");
}
}
cell# is the ElementId of the cell you want to hide