Answered by:
Hide field from GridView but not DetailsView

Question
-
User-515122190 posted
I have been working with Dynamic Data recently and I am really impressed with it -- its a great start. While working on a test project that had 15 or so tables with the average number of fields per table being aorund 25 it occured to me that it would be great if there was a way via attributes to hid a field from being displayed in the GridView while still allowing it to be shown in the Details view. While I do realize that I can do this with custom pages, it gets tedous to do this when the number of tables and fields starts getting pretty large.
Example of idea:
public partial class Custom
{
public object FirstName;
public object LastName;
// This field will be hidden from the GridView and shown in the Details view
[ListView(Hidden=true)]
public object AddressLine1;// This field will be hidden from the GridView and shown in the Details view
[ListView(Hidden=true)]
public object AddressLine2;public object AddressPostalCode;
public object AddressCountry;
// This field will be shown in the GridView but not in the Details view
[DetailsView(Hidden=true)]
public object LastModifiedBy;}
Tuesday, September 9, 2008 9:44 PM
Answers
-
User1641955678 posted
Question: Any idea on how I can tell which type of view will be generated from within the FieldGenerator class? I know I have access to the MetaTable, but I cannot seem to find anything that would indicate the type of parent ASP.NET control that will be the container.
IAutoFieldGenerator.GenerateFields takes a Control, which is what you want to look at. e.g. if it's a GridView, do this, if it's a DetailsView, do that, etc...
David
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, September 10, 2008 3:36 PM
All replies
-
User1641955678 posted
You should be able to do this by wrting a custom field generator. For a sample of what that looks like, look for AdvancedFieldGenerator in the Futures app. So basically, you'd create your own attributes, and then in your generator you would selectively skip columns based on what attributes you find, and what type of control it's dealing with.
David
Wednesday, September 10, 2008 1:44 AM -
User-330204900 posted
hi RavensOrb see my series on my blog:
- Introduction - A DynamicData Attribute Based Permission Solution using User Roles.
- Part 1 - Permissions Attribute (Metadata) Classes.
- Part 2 - Sample Metadata for project.
- Part 3 - The Helper Extension Methods.
- Part 4 - Limit Tables shown on Default page and List, Edit & Details etc.
- Part 5 - Generate Columns/Rows (using IAutoFieldGenerator)
- Part 6 - Miscellaneous bits
- Part 7 - Updating the ListDetails Page
- DynamicData - Limit the Filter Fields
-
DynamicData - Automatic Column Update
In which I control what the user see via atributes based on the users roles.
Hope this helps [:D]
Wednesday, September 10, 2008 3:21 AM -
User-515122190 posted
hi RavensOrb see my series on my blog:
- Introduction - A DynamicData Attribute Based Permission Solution using User Roles.
- Part 1 - Permissions Attribute (Metadata) Classes.
- Part 2 - Sample Metadata for project.
- Part 3 - The Helper Extension Methods.
- Part 4 - Limit Tables shown on Default page and List, Edit & Details etc.
- Part 5 - Generate Columns/Rows (using IAutoFieldGenerator)
- Part 6 - Miscellaneous bits
- Part 7 - Updating the ListDetails Page
- DynamicData - Limit the Filter Fields
-
DynamicData - Automatic Column Update
In which I control what the user see via atributes based on the users roles.
Hope this helps
Question: Any idea on how I can tell which type of view will be generated from within the FieldGenerator class? I know I have access to the MetaTable, but I cannot seem to find anything that would indicate the type of parent ASP.NET control that will be the container.
Wednesday, September 10, 2008 6:25 AM -
User-515122190 posted
You should be able to do this by wrting a custom field generator. For a sample of what that looks like, look for AdvancedFieldGenerator in the Futures app. So basically, you'd create your own attributes, and then in your generator you would selectively skip columns based on what attributes you find, and what type of control it's dealing with.
DavidThanks for the suggestion -- I'll take a look at the sample.
Wednesday, September 10, 2008 6:27 AM -
User1641955678 posted
Question: Any idea on how I can tell which type of view will be generated from within the FieldGenerator class? I know I have access to the MetaTable, but I cannot seem to find anything that would indicate the type of parent ASP.NET control that will be the container.
IAutoFieldGenerator.GenerateFields takes a Control, which is what you want to look at. e.g. if it's a GridView, do this, if it's a DetailsView, do that, etc...
David
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, September 10, 2008 3:36 PM