The NVTableTemplate component is used to display a list of structured information. Each line represent an item in the list, and a cell represent a property/piece of information of this item.
Responsive
Responsive define if the table need to get a vertical display when on small screen (<640px).
In order to accomplish the table heading for each line on small screen, we need to add on each cell a data-table-heading attributes.
Type | Default Value |
---|
boolean | false |
Firstname |
Lastname |
Email |
ZipCode |
John |
Smith |
john.smith@gmail.com |
1000 |
Jean |
Moulin |
jean.moulin@gmail.com |
1200 |
Bart |
Simpson |
bart.simpson@gmail.com |
1180 |
<NVTableTemplate Responsive TableItems="@_persons" Context="item">
<NVTableHead>
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
<th>ZipCode</th>
</NVTableHead>
<NVTableRow>
<td data-table-heading="Firstname">@item.Firstname</td>
<td data-table-heading="Lastname">@item.Lastname</td>
<td data-table-heading="Email">@item.Email</td>
<td data-table-heading="ZipCode">@item.ZipCode</td>
</NVTableRow>
</NVTableTemplate>
...
@code {
List<Person> _persons = new List<Person>
{
new Person {Firstname = "John", Lastname = "Smith", Email = "john.smith@gmail.com", ZipCode = "1000"},
new Person {Firstname = "Jean", Lastname = "Moulin", Email = "jean.moulin@gmail.com", ZipCode = "1200"},
new Person {Firstname = "Bart", Lastname = "Simpson", Email = "bart.simpson@gmail.com", ZipCode = "1180"},
};
private class Person
{
public string Firstname { get; set; }
public string Lastname { get; set; }
public string Email { get; set; }
public string ZipCode { get; set; }
}
}
<div class="nv-table nv-table-responsive">
<table>
<thead>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
<th>ZipCode</th>
</tr>
</thead>
<tbody>
<tr>
<td data-table-heading="Firstname">John</td>
<td data-table-heading="Lastname">Smith</td>
<td data-table-heading="Email">john.smith@gmail.com</td>
<td data-table-heading="ZipCode">1000</td>
</tr>
<tr>
<td data-table-heading="Firstname">Jean</td>
<td data-table-heading="Lastname">Moulin</td>
<td data-table-heading="Email">jean.moulin@gmail.com</td>
<td data-table-heading="ZipCode">1200</td>
</tr>
<tr>
<td data-table-heading="Firstname">Bart</td>
<td data-table-heading="Lastname">Simpson</td>
<td data-table-heading="Email">bart.simpson@gmail.com</td>
<td data-table-heading="ZipCode">1180</td>
</tr>
</tbody>
</table>
</div>
Striped
Striped define if the table need to display a alternate color for each line of the table.
Type | Default Value |
---|
boolean | false |
Firstname |
Lastname |
Email |
ZipCode |
John |
Smith |
john.smith@gmail.com |
1000 |
Jean |
Moulin |
jean.moulin@gmail.com |
1200 |
Bart |
Simpson |
bart.simpson@gmail.com |
1180 |
<NVTableTemplate Striped TableItems="@_persons" Context="item">
<NVTableHead>
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
<th>ZipCode</th>
</NVTableHead>
<NVTableRow>
<td>@item.Firstname</td>
<td>@item.Lastname</td>
<td>@item.Email</td>
<td>@item.ZipCode</td>
</NVTableRow>
</NVTableTemplate>
...
@code {
List<Person> _persons = new List<Person>
{
new Person {Firstname = "John", Lastname = "Smith", Email = "john.smith@gmail.com", ZipCode = "1000"},
new Person {Firstname = "Jean", Lastname = "Moulin", Email = "jean.moulin@gmail.com", ZipCode = "1200"},
new Person {Firstname = "Bart", Lastname = "Simpson", Email = "bart.simpson@gmail.com", ZipCode = "1180"},
};
private class Person
{
public string Firstname { get; set; }
public string Lastname { get; set; }
public string Email { get; set; }
public string ZipCode { get; set; }
}
}
<div class="nv-table nv-table-striped">
<table>
<thead>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
<th>ZipCode</th>
</tr>
</thead>
<tbody>
<tr>
<td>John</td>
<td>Smith</td>
<td>john.smith@gmail.com</td>
<td>1000</td>
</tr>
<tr>
<td>Jean</td>
<td>Moulin</td>
<td>jean.moulin@gmail.com</td>
<td>1200</td>
</tr>
<tr>
<td>Bart</td>
<td>Simpson</td>
<td>bart.simpson@gmail.com</td>
<td>1180</td>
</tr>
</tbody>
</table>
</div>
NVTableHead
RenderFragment used to put heading line and heading cell in the table.
Type | Default Value |
---|
RenderFragment | null |
Firstname |
Lastname |
Email |
ZipCode |
<NVTableTemplate TableItems="@_persons" Context="item">
<NVTableHead>
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
<th>ZipCode</th>
</NVTableHead>
</NVTableTemplate>
...
@code {
List<Person> _persons = new List<Person>
{
new Person {Firstname = "John", Lastname = "Smith", Email = "john.smith@gmail.com", ZipCode = "1000"},
new Person {Firstname = "Jean", Lastname = "Moulin", Email = "jean.moulin@gmail.com", ZipCode = "1200"},
new Person {Firstname = "Bart", Lastname = "Simpson", Email = "bart.simpson@gmail.com", ZipCode = "1180"},
};
private class Person
{
public string Firstname { get; set; }
public string Lastname { get; set; }
public string Email { get; set; }
public string ZipCode { get; set; }
}
}
<div class="nv-table">
<table>
<thead>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
<th>ZipCode</th>
</tr>
</thead>
</table>
</div>
TableItems
Data used for the row rendering.
Type | Default Value |
---|
List<TItem> | List<TItem> (mandatory) |
Firstname |
Lastname |
Email |
ZipCode |
John |
Smith |
john.smith@gmail.com |
1000 |
Jean |
Moulin |
jean.moulin@gmail.com |
1200 |
Bart |
Simpson |
bart.simpson@gmail.com |
1180 |
<NVTableTemplate Striped TableItems="@_persons" Context="item">
<NVTableHead>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
<th>ZipCode</th>
</tr>
</NVTableHead>
<NVTableRow>
<td>@item.Firstname</td>
<td>@item.Lastname</td>
<td>@item.Email</td>
<td>@item.ZipCode</td>
</NVTableRow>
</NVTableTemplate>
...
@code {
List<Person> _persons = new List<Person>
{
new Person {Firstname = "John", Lastname = "Smith", Email = "john.smith@gmail.com", ZipCode = "1000"},
new Person {Firstname = "Jean", Lastname = "Moulin", Email = "jean.moulin@gmail.com", ZipCode = "1200"},
new Person {Firstname = "Bart", Lastname = "Simpson", Email = "bart.simpson@gmail.com", ZipCode = "1180"},
};
private class Person
{
public string Firstname { get; set; }
public string Lastname { get; set; }
public string Email { get; set; }
public string ZipCode { get; set; }
}
}
<div class="nv-table nv-table-striped">
<table>
<thead>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
<th>ZipCode</th>
</tr>
</thead>
<tbody>
<tr>
<td>John</td>
<td>Smith</td>
<td>john.smith@gmail.com</td>
<td>1000</td>
</tr>
<tr>
<td>Jean</td>
<td>Moulin</td>
<td>jean.moulin@gmail.com</td>
<td>1200</td>
</tr>
<tr>
<td>Bart</td>
<td>Simpson</td>
<td>bart.simpson@gmail.com</td>
<td>1180</td>
</tr>
</tbody>
</table>
</div>
NVTableRow
RenderFragment used to put body line and body cell in the table.
Type | Default Value |
---|
RenderFragment<TItem> | null |
John |
Smith |
john.smith@gmail.com |
1000 |
Jean |
Moulin |
jean.moulin@gmail.com |
1200 |
Bart |
Simpson |
bart.simpson@gmail.com |
1180 |
<NVTableTemplate TableItems="@_persons" Context="item">
<NVTableRow>
<td>@item.Firstname</td>
<td>@item.Lastname</td>
<td>@item.Email</td>
<td>@item.ZipCode</td>
</NVTableRow>
</NVTableTemplate>
...
@code {
List<Person> _persons = new List<Person>
{
new Person {Firstname = "John", Lastname = "Smith", Email = "john.smith@gmail.com", ZipCode = "1000"},
new Person {Firstname = "Jean", Lastname = "Moulin", Email = "jean.moulin@gmail.com", ZipCode = "1200"},
new Person {Firstname = "Bart", Lastname = "Simpson", Email = "bart.simpson@gmail.com", ZipCode = "1180"},
};
private class Person
{
public string Firstname { get; set; }
public string Lastname { get; set; }
public string Email { get; set; }
public string ZipCode { get; set; }
}
}
<div class="nv-table">
<table>
<tbody>
<tr>
<td>John</td>
<td>Smith</td>
<td class="text-gray-800">john.smith@gmail.com</td>
<td>1000</td>
</tr>
<tr>
<td>Jean</td>
<td>Moulin</td>
<td class="text-gray-800">jean.moulin@gmail.com</td>
<td>1200</td>
</tr>
<tr>
<td>Bart</td>
<td>Simpson</td>
<td class="text-gray-800">bart.simpson@gmail.com</td>
<td>1180</td>
</tr>
</tbody>
</table>
</div>