Skip to content

Commit 3efb7f9

Browse files
authored
QuickGrid empty rows and border styling
1 parent 78bbce4 commit 3efb7f9

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

aspnetcore/blazor/components/quickgrid.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,63 @@ To provide a UI for pagination, add a [`Paginator` component](xref:Microsoft.Asp
138138

139139
In the running app, page through the items using a rendered `Paginator` component.
140140

141+
QuickGrid renders additional empty rows to fill in the final page of data when used with a `Paginator` component. In .NET 9 or later, empty data cells (`<td></td>`) are added to the empty rows. The empty rows are intended to facilitate rendering the QuickGrid with stable row height and styling across all pages. You can apply styles to the rows using [CSS isolation](xref:blazor/components/css-isolation) by wrapping the `QuickGrid` component in a wrapper element, such as a `<div>`, and applying a row style with `::deep` [pseudo-elements](https://developer.mozilla.org/docs/Web/CSS/Pseudo-elements):
142+
143+
```css
144+
::deep tr {
145+
height: 2em;
146+
}
147+
```
148+
149+
:::moniker range=">= aspnetcore-9.0"
150+
151+
<!-- UPDATE 10.0 Check on https://github.com/dotnet/aspnetcore/issues/59078 to see
152+
if an empty row template feature is added that will result in an
153+
update the following content for >=10.0. -->
154+
155+
In .NET 9 or later, Bootstrap styling adds a bottom border to empty row data cells, which results in a UI artifact. To remove the border styling of the empty cells on these rows, use [CSS isolation](xref:blazor/components/css-isolation).
156+
157+
Consider the following QuickGrid placed in the app's `Index` component. The `QuickGrid` component has a wrapper `<div>` element, which permits you to apply `::deep` [pseudo-elements](https://developer.mozilla.org/docs/Web/CSS/Pseudo-elements) to the QuickGrid.
158+
159+
`Index.razor`:
160+
161+
```razor
162+
<div>
163+
<QuickGrid ... Pagination="pagination">
164+
...
165+
</QuickGrid>
166+
</div>
167+
168+
<Paginator State="pagination" />
169+
170+
@code {
171+
private PaginationState pagination = new PaginationState { ItemsPerPage = 10 };
172+
173+
...
174+
}
175+
```
176+
177+
In the following isolated CSS styles:
178+
179+
* Row cells populated with data are displayed.
180+
* Empty row data cells aren't displayed, which avoids empty row cell borders rendering per the Bootstrap style.
181+
182+
`Index.razor.css`:
183+
184+
```css
185+
::deep tr:has(> td:not(:empty)) > td {
186+
display: table-cell;
187+
}
188+
189+
::deep td:empty {
190+
display: none;
191+
}
192+
```
193+
194+
:::moniker-end
195+
196+
For more information on using `::deep` [pseudo-elements](https://developer.mozilla.org/docs/Web/CSS/Pseudo-elements) with CSS isolation, see <xref:blazor/components/css-isolation#child-component-support>.
197+
141198
## Custom attributes and styles
142199

143200
QuickGrid also supports passing custom attributes and style classes (<xref:Microsoft.AspNetCore.Components.QuickGrid.QuickGrid%601.Class%2A>) to the rendered table element:

0 commit comments

Comments
 (0)