Show/Hide a field from a table in report based on user selection

Dear All,
I have a small question. How can we show or hide a column in a report based on user selection in the dialog box. I can get the user choice from dialog. No problem on that part. But I was wondering how I can use the user choice to show/hide a field/column which I added to a section group from one of the table that the report is based on.

Thanks in advance for your time and help.

1263.hide-field.jpg

Set the control’s auto declaration property to Yes to access it’s properties. In run method before super set the visibility property based on the user selection.

Thanks a lot Kranthi. You have always been so helpful.

I really appreciate.

Kranthi, one more precision that I need if you have a moment. I am able to hide the field data based on user selection. But the field header remains visible.

How to hide the field header/column name.

Cheers.

You mean the column label? is it placed in a separate section in the report?

Dear Kranthi,

Yeah I mean the column label does not hide when I hide the column data. The code line is in the executeSection and is in bold. It hides column rows but not the column header.

Thanks for your support.

public void executeSection()

{

if (!inShowAccrual && ledgerJournalTrans.Voucher != oldLedgerJournalTrans.Voucher)

{

element.execute(1);

element.execute(2);

amountvoucher = 0;

}

if (!showAccrualTrans)

{

LedgerJournalTrans_TransDate_1.visible(false);

}

super();

}

If the label is not in a separate section, then setting the field visible to false will not be showing the label as well.

If it is in separate section as a field, then you need to set its visible property.

Dear Kranthi,

After your initial response I guessed that some other execute section was responsible for column header still being visible. I commented the lines below to hide the column header. It seems to work fine.

public void executeSection()

{

if(newJournalHeader)

{

super();

}

//element.executeBodyColumnHeadings(tablenum(LedgerJournalTrans));

//element.columnHeadings(tablenum(LedgerJournalTrans));

}

Here is the screenshot of the problem and solution

8475.field-header-visible.jpg

0508.field-header-visible-2.jpg

Thanks a lot for your help.

Have a nice day.