Column Selection
Name | Movie Director | Movie Genre | Released |
---|---|---|---|
Star Wars | George Lucas | Sci-Fi | 1997 |
Reservoir Dogs | Quentin Tarantino | Thriller | 1992 |
Airplane! | David and Jerry Zucker and Jim Abrahams | Slapstick | 1980 |
Automatically Select Columns
@(await Html
.SimpleGrid(Model.Take(3))
.AddColumnsForModel()
.RenderAsync())
This will automatically pick up columns from the Model's properties.
It will respect the Display Attribute "AutoGenerateField" to suppress specific properties:
[Display(AutoGenerateField = false)]
Which is why the "Cast" column is not included in the Grid on the left.
Name | Movie Director | Movie Genre | Released |
---|---|---|---|
Star Wars | George Lucas | Sci-Fi | 1997 |
Reservoir Dogs | Quentin Tarantino | Thriller | 1992 |
Airplane! | David and Jerry Zucker and Jim Abrahams | Slapstick | 1980 |
Select Specific Columns
@(await Html
.SimpleGrid(Model.Take(3))
.AddColumnFor(movie => movie.Name)
.AddColumnFor(movie => movie.Director)
.AddColumn(col => col.For(movie => movie.Genre))
.AddColumn(col => col.For(movie => movie.Released))
.RenderAsync())
Note that AddColumnFor
is a shortcut for calling AddColumn
followed by For
inside.
You will want to use AddColumn
if you want to further customize the Column as you will see in other Samples.
Name | Movie Genre |
---|---|
Star Wars | Sci-Fi |
Reservoir Dogs | Thriller |
Airplane! | Slapstick |
Remove Columns
@(await Html
.SimpleGrid(Model.Take(3))
.AddColumnsForModel()
.RemoveColumn(1) // by zero based index
.RemoveColumn("Released") // by column header
.RenderAsync())