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
Related
I need a help on applying common drop down values to multiple selected rows in a Webix datatable. Let's say I want to select all the rows of my datatable (by Ctrl+click) for which the 'Name' column has value as 'Mark' and then want to apply a common color for them (for example : green) by clicking so that it gets applied on all the rows at one go.
The snippet is here : https://webix.com/snippet/1162ccd1
Any help on how can this be achieved would be appreciated.
Thanks in advance.
Further to this post, I am including a re-phrased and a half-way solution below for the experts to dispel any confusion about the requirement :
It does not necessarily have to be those rows which have 'Name' as 'Mark'. I put it that way to give an example. Basically, it could be any randomly selected row either consecutive or haphazard and selecting a common value for them from the drop down of the 'color' column (it could be any color in that drop down ) so that its value gets assigned to those cells of those selected rows. Note, selecting a color should not change the color of the row, so there is no css effect I want here.
I have so far written the code like below, which is able to fetch the selected rows.
rows = $$("mytable").getSelectedId(true);
for (i in rows) {
id = rows[i];
item = $$("mytable").getItem(id);
/* below effect has to happen from the drop down of data table gui */
item.id2 = "green"; //for example, it could be any value
}
Can anybody please help me in:
i) how can I apply the value selected from the drop down of data table to all the selected rows ?
ii) Secondly, how can I trigger this code ( through which event ?) once they are selected in the data table and the value is chosen from the drop down ?
Thanks.
You can do something like this by adding the onBeforeFilter event, and track only color filter ("id2" in your snippet):
onBeforeFilter: function(id, value, config) {
if (id === "id2") {
const selected = this.getSelectedId(true);
const color = this.getFilter("id2").value;
for (let row in selected) {
const item = this.getItem(selected[row]);
item["id2"] = color;
this.updateItem(item.id, item);
}
}
}
Sample is here https://webix.com/snippet/538e1ca0
But I think this is not the best way.
You can also create a context menu that is displayed by right-clicking on the table and making a choice of values in it.
I got know how to hide crosstab column in Excel Birt export at "onprepare" event of crosstab or cell in this question.
My question is how to access data value of a cell at "onPrepareCell" event so for example if value ="EURO" set width of this cell to 0 as something like as below:
function onPrepareCell( cell, reportContext )
if(cell.getReport.getDataItem("CURRENCY") == "EURO" ){
if( cell.getCellID() == cell#){
reportContext.getDesignHandle().getElementByID(ElementId#).setStringProperty("width","0px");
}
}
but I can't extract value from IDataItem.
We can't access dataItem in
onPrepareCell( cell, reportContext )
Instead use the Report parameter from outside of crosstab
onPrepareCell(cell, reportContext){
if (reportContext.getParameterValue("CURRENCY") == "EURO") {
if (cell.getCellID() == cell#){
reportContext.getDesignHandle().getElementByID(ElementId#).setStringProperty("width", "0px");
}
}
}
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.
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/
Is it possible to render a Grid with one row selected as default (set the right page number and highlight the row)?
For highlighting, try using the "OnRowDataBound" event
.ClientEvents(events => events.OnRowDataBound("onRowDataBound"))
with something like
function onRowDataBound(e) {
var myId = $('#MyId').val();
if (e.dataItem.Id == myId)
e.row.className = 't-state-selected';
}
I'm still trying to figure out how to set the correct initial page number. This bloke might be on to something.
Use the Grid RowAction method, eg:
.RowAction(row => row.Selected = row.DataItem.CustomerCode.Equals(ViewBag.ID))
It is perhaps possible if you iterate in the grid source, locate the row which has to be selected in it, than use a formula to detect on which page will be displayed, and finally change the page index on initial load and select it.