Access data value of a cell at "onPrepareCell" event in Birt crosstab - birt

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");
}
}
}

Related

onEdit trigger based on OUTCOME (VALUE) from formula result

I am trying to create an AUTOSORT onEdit() script that is only triggered when a value in Column D (4) matches a certain text. In this pattern, when the onEdit trigger becomes active, range.sort({column:11,ascending:true}) is used in the active sheet, but is limited to a preselected range of sheets.
I have a script for when a cell is changed completely, but unfortunately doesn't run when the value is changed due to a formula.
What I would like to have is a script that checks the outcome of a formula for a specific TEXT in Column D (4) whenever it is changed.
What I have so far (not working at this moment):
function onEdit(e) {
multiSortColumns(e);
}
function multiSortColumns(e) {
if (e.range.columnStart == 4 && e.range.getValue() == 'CHANGE OF DATE') {
var sheets = ["Sheet1", "Sheet2", , ,];
var sheet = e.range.getSheet();
if (sheets.includes(sheet.getSheetName())) {
var range = sheet.getRange("A5:bY600");
range.sort({ column: 11, ascending: true });
e.source.toast('Sort complete.');
}
}
}
Because the value in column D is not manually edited but through a formula or function, onEdit(e) doesn't consider that as an event as explained in the limitations below:
- Script executions and API requests do not cause triggers to run. For example, calling Range.setValue() to edit a cell does not cause the spreadsheet's onEdit trigger to run.
But let's say the cell that is manually edited is in column A and based on that, the cell value in the same row in column D changes to "CHANGE OF DATE", you can adjust your code by catching that edit event in column A :
function onEdit(e) {
multiSortColumns(e);
}
function multiSortColumns(e) {
//var refcell = SpreadsheetApp.getActiveSheet().getActiveCell();
if (e.range.columnStart == 1 && e.range.offset(0,3).getValue() == 'CHANGE OF DATE') { //i.e. col 1 is edited and col 1+3 shows "CHANGE OF DATE"
var sheets = ["Sheet1", "Sheet2", , ,];
var sheet = e.range.getSheet();
if (sheets.includes(sheet.getSheetName())) {
var range = sheet.getRange("A5:bY600");
range.sort({ column: 11, ascending: true });
e.source.toast('Sort complete.');
}
}
}
Your column D is still used as a pre-condition for sorting but using offset() relative to column A where the edit event actually happened.

Oracle APEX Interactive Grid: Is there a way to get the corresponding column name, when clicking in a data cell in the Interactive Grid

I have a Dynamic Action which should get the data from the model, depending on the clicked column. Let 's say I have two columns in the interactive grid, column A and B. Depending on the column I clicked in, the DA should be executed and execute a query with the value from column A or B.
The DA is actived on doubleclick and I have the following source to get the value from the IG model.
var regionStaticId = $(this.triggeringElement).closest("div.js-apex-region").attr('id');
var grid = apex.region( regionStaticId ).widget().interactiveGrid("getViews", "grid");
var model = grid.model;
var record = grid.getSelectedRecords()[0];
var value;
// Code to find the the clicked column comes here
if (record) {
value = model.getValue(record, columnName);
}
Now, what I can do is add an extra css class to the particular cells, with the name of the source column. But that would be like hardcoding in my opinion. Like this.
if ($(this.triggeringElement).hasClass('columnA')) {
columnName = 'COLUMN_A';
}
else if ($(this.triggeringElement).hasClass('columnB')) {
columnName = 'COLUMN_B';
}
Is there a way to determine the clicked column, based on the triggering element?
Help is very much appreciated.

popup lov column show as [object Object]

I need to set the value from popup lov column in item when (selection change (interactive grid)), but the value appears like [object Object]
This is my code:
this.data.selectedRecords.length != 1 ? '': this.data.model.getValue(
this.data.selectedRecords[0], "DEPTNO")
How I can show the true value?
//Use the below code in the Apex Page
//Event: Selection Change Interactive grid
//True Action: Javascript code
//To get the IG column values based on selection.
//EMP is the Static ID of the IG region.
var record;
var ig$=apex.region("EMP").widget();
var grid=ig$.interactiveGrid("getViews","grid");
var model= ig$.interactiveGrid("getViews","grid").model;
var selectedRecords=apex.region("EMP").widget().interactiveGrid("getViews","grid").view$.grid
("getSelectedRecords");
//Loop through the rows in IG.
for (idx=0; idx < selectedRecords.length; idx++)
{
//To show the value of modal LOV in browser console
//EMP_NAME is the name of the IG column
//.v is used to get the value of the object.
console.log(selectedRecords[idx][model.getFieldKey("EMP_NAME")].v);
}

jqGrid - Issue with editrules when dynamically changing editable property on column model

I am using inline row editing for a jqGrid.
I loop through each row and before calling editRow(), I set the editable property on the column model for certain rows as FALSE (making the column for some rows as non editable). This all works fine until I add editrules to the column model. I get a javascript error "a is undefined" when saving the rows.
Question - Is there a way to make a column non-editable for certain rows and for other rows have an edit rule defined?
Any inputs is greatly appreciated!
I was able to solve this by setting/resetting the editrules property on the colModel before calling saveRow() on each row. Below is the code snippet
function updateEditRuleProp() {
var qtyRule = {required:true, number:true, minValue:1};
if (condition to disable editrules) {
qtyRule = null;
}
jQuery("#tableId").jqGrid('getColProp', 'yourColumName').editrules = qtyRule;
}
Here is the code that calls the above function
var $this = jQuery("#tableId"), ids = $this.jqGrid('getDataIDs'), i, l = ids.length;
for (i = 0; i < l; i++) {
updateEditRuleProp();
jQuery("#tableId").jqGrid('saveRow', ids[i]);
}

Control crosstab column visibility with report parameter in BIRT

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

Resources