Back to forum

How to pass data from containing class into onCustomizeCell() function

Closed

Hello,
Firstly thank you for your excellent product.  Is there a way that additional data can be passed to an onCustomizeCell function (using webdatarocks with Angular 7)?
My function looks like this

 onCustomizeCell( cell: WebDataRocks.CellBuilder, data: WebDataRocks.Cell): void {
if (data.isClassicTotalRow) cell.addClass("fm-total-classic-r");
if (data.isGrandTotalRow) cell.addClass("fm-grand-total-r");
if (data.isGrandTotalColumn) cell.addClass("fm-grand-total-c");
if (data.value==0) {
if (!data.isTotal && data.columns[0].hierarchyCaption=='platform') {
var platform=data.columns[0].caption;
var name=data.rows[0].caption
cell.text=`<a href='#/search?stringQuery={"restriction": [["kit", "2018.1.1.539", "="], ["name", "${name}", "="], ["platform", "${platform}", "="]], "projection":["result","triageStatus"]}', target='_blank', style='text-decoration: underline'>FAIL</a>`
// cell.text=`<a href='#/search?stringQuery={"restriction": [["kit", "2018.1.1.539", "="], ["name", "${name}", "="], ["platform", "${platform}", "="]], "projection":${origJsonQueryObj.projection}}', target='_blank', style='text-decoration: underline'>FAIL</a>`
} else {
cell.text="FAIL"
}
}
if (data.value==1) cell.text="PASS"
if (data.value==2) cell.text="SKIP"
}

And it works fine when cell.text is all hardcoded except for values accessible via the ‘cell’ and ‘data’ parameters, but I need to be able to construct the cell text using some data from the containing component class (as in the commented-out version of the cell.text= line, with origJsonQueryObj as passed-in data). 

I tried defining it as a var in the component class as well as a property in the component class, but neither is accessible inside onCustomizeCell, and ‘this’ doesn’t point to the containing component class when inside the function since it’s defined using fat arrow syntax.

I also tried modifying the webdatarocks code (locally) to accept another parameter to onCustomizeCell, either an object or the containing class ‘this’, but was not successful.

Can you please suggest any approach?

Thank you in advance for any help.

1 answer

Olga August 29, 2019

Never mind, got  it – need to use fat arrow syntax when redefining callback function locally so as to close around containing ‘this’

This question is now closed

Move up