locked
How can one hide a column on the List page only? RRS feed

  • Question

  • User-1614457691 posted

    All --

    Please help.

    How can one hide a column on the List page only?

    Is there an attribute setting for that?

    I want to show the column on the Detail page and on the Insert page and on the Edit page-- but, I do not want to show it on the List page.

    I would rather not have to create a custom template-- I would rather want to decorate the partial class Metadata, etc.

    Can you help?

    Please advise.

    Thank you.

    -- Mark Kamoski

     

    Monday, October 6, 2008 10:45 AM

Answers

  • User-330204900 posted

    Hi Mark you could use a column generator as used in DD Futures and in my tutorials on permissions:

    // add ColumnNameFieldsManager to set column names
    GridView1.ColumnsGenerator = new ColumnNameFieldsManager(table);
    

    And here's the Column Generator class

    public class ColumnNameFieldsManager : IAutoFieldGenerator
    {
    	protected MetaTable _table;
    
    	public ColumnNameFieldsManager(MetaTable table)
    	{
    		_table = table;
    	}
    
    	public ICollection GenerateFields(Control control)
    	{
    		List<DYNAMICFIELD> oFields = new List<DYNAMICFIELD>();
    
    		foreach (MetaColumn column in _table.Columns)
    		{
    
    			// carry on the loop at the next column  
    			// if scaffold table is set to false or DenyRead
    			if (!column.Scaffold)
    				continue;
    
    			DynamicField f = new DynamicField();
    
    			f.DataField = column.Name;
    			// do your column name look up here
    			f.HeaderText = "***" + column.Name + "***";
    			oFields.Add(f);
    		}
    		return oFields;
    	}
    }
    

    You could then skip the columns you don't want based on your own attributes 

    Hope this helps [:D]

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 6, 2008 10:56 AM