Forum > LazReport
[Solved] LazReport: show/hide an image depending on field value
(1/1)
lainz:
Hi, I have a report with an image called 'OFERTA' and I want to show/hide depending on the 'Oferta' field on my query.
I've added BeforePrint event, that uses a TfrReport as Sender. I use the sender as report to find the image, check if <> nil and toggle visibility.
I've debugged the code, and yes frimg.Visible is True / False depending on the value of ('Oferta' = 'T').
Despite all being ok, the image is or always visible or always hidden, depending on how it was designed the report!
Help %)
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TfrmListProductos.frProductosBeforePrint(Sender: TfrReport);var frimg: TFRPictureView = nil;begin if Productos.FindField('bOferta') <> nil then // ok begin frimg:=TFRPictureView(Sender.FindObject('OFERTA')); // ok if Assigned(frimg) then // ok begin frimg.Visible := (frDBDataSetProductos.DataSet.FieldByName('Oferta').AsString = 'T'); // this is ok end; end;end;
lainz:
Solved:
In the script of the image in the report, I check 'script' checkbox and add this code:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---if [sqlqyProductos.Oferta] ='T' thenPicture1.Visible:=True;
That solves the problem.. :)
Navigation
[0] Message Index