Master/detail - hide master colums

This public forum is for user-to-user discussions of ASP.NET Maker. Note that this is not support forum.
Post Reply
Andros
User
Posts: 111

Master/detail - hide master colums

Post 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?


MichaelG
User
Posts: 1095

Post 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;

Andros
User
Posts: 111

Post 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?


MichaelG
User
Posts: 1095

Post by MichaelG »

The master table object can be obtained by Resolve("<MasterTableName>") so you can simply use Resolve("<MasterTableName>").FieldByName(item).


Post Reply