Page 1 of 1
Master/detail - hide master colums
Posted: Sat Apr 29, 2023 2:04 am
by Andros
Hi. I have a master/detail scenario (customersorders + customersordersitems).
I want to make some fields hidden in the master and in the detail tables.
In the List page / Page_DataRendering of the master table I do (and it works):
public void Page_DataRendering(ref string header) {
// Example:
//header = "your header";
foreach (string item in jc_HiddenFields(CurrentTable.Name)) { //the function returns a comma separated list of the fields to hidden for the CurrentTable.Name table
var myfield = FieldByName(item);
myfield.Visible = false;
}
}
In the Preview page / Page_DataRendering event for the detail table I have the same code, and it works for the detail fields.
Now I want in the master detail page (e.g. customersordersitemslist?showmaster=customersorders&fk_CustomerOrderID=1) to hide the master table fields also.
How to do it?
Re: Master/detail - hide master colums
Posted: Mon May 01, 2023 7:52 am
by MichaelG
You can use the Page_Render server event of the detail list page to hide columns in the master table. For example:
if (CurrentMasterTable == "<MasterTableName>")
Resolve("<MasterTableName>").<MasterFieldName>.Visible = false;
Re: Master/detail - hide master colums
Posted: Tue May 02, 2023 8:23 pm
by Andros
Ok thank you.
I obtain the list of fields to hide from a function to which I pass the name of the table; then I loop the items (comma separated values), get the field object from the name, and then set the Visible to false.
For the detail table fields in Page_DataRendering event I do this with the following code:
public void Page_DataRendering(ref string header) {
foreach (string item in HiddenFields(CurrentTable.Name)) {
var myfield = FieldByName(item);
myfield.Visible = false;
}
}
So in the Page_Render I need a function like FieldByName to obtain the same result, but for the master table fields. How to do it?
Re: Master/detail - hide master colums
Posted: Wed May 03, 2023 9:14 am
by MichaelG
The master table object can be obtained by Resolve("<MasterTableName>") so you can simply use Resolve("<MasterTableName>").FieldByName(item).