You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: aspnetcore/blazor/components/quickgrid.md
+22-4Lines changed: 22 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -138,18 +138,36 @@ To provide a UI for pagination, add a [`Paginator` component](xref:Microsoft.Asp
138
138
139
139
In the running app, page through the items using a rendered `Paginator` component.
140
140
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):
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.
142
+
143
+
## Apply row styles
144
+
145
+
Apply styles to rows using [CSS isolation](xref:blazor/components/css-isolation), which can include styling empty rows for `QuickGrid` components that [page data with a `Paginator` component](#page-items-with-a-paginator-component).
146
+
147
+
Wrap the `QuickGrid` component in a wrapper block element, for example a `<div>`:
148
+
149
+
```diff
150
+
+ <div>
151
+
<QuickGrid ...>
152
+
...
153
+
</QuickGrid>
154
+
+ </div>
155
+
```
156
+
157
+
Apply a row style with the `::deep`[pseudo-element](https://developer.mozilla.org/docs/Web/CSS/Pseudo-elements). In the following example, row height is set to `2em`, including for empty data rows.
158
+
159
+
`{COMPONENT}.razor.css`:
142
160
143
161
```css
144
162
::deep tr {
145
163
height: 2em;
146
164
}
147
165
```
148
166
149
-
To hide the empty row data cells rendered by the QuickGrid, use CSS styling. In the following isolated CSS styles:
167
+
Alternatively, use the following CSS styling approach:
150
168
151
-
*Row cells populated with data are displayed.
152
-
*Empty row data cells aren't displayed, which avoids empty row cell borders from rendering per Bootstrap styling.
169
+
*Display row cells populated with data.
170
+
*Don't display empty row cells, which avoids empty row cell borders from rendering per Bootstrap styling.
Copy file name to clipboardExpand all lines: aspnetcore/blazor/tutorials/movie-database-app/part-8.md
+40-2Lines changed: 40 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -118,11 +118,11 @@ Run the app and navigate to the movies `Index` page. You can page through the mo
118
118
119
119
The component is *interactive*. The page doesn't reload for paging to occur. The paging is performed live over the SignalR connection between the browser and the server, where the paging operation is performed on the server with the rendered result sent back to the client for the browser to display.
120
120
121
-
Change <xref:Microsoft.AspNetCore.Components.QuickGrid.PaginationState.ItemsPerPage%2A> to a more reasonable value, such as 10 items per page:
121
+
Change <xref:Microsoft.AspNetCore.Components.QuickGrid.PaginationState.ItemsPerPage%2A> to a more reasonable value, such as five items per page:
@@ -199,6 +199,44 @@ Filtering database records is performed on the server, and the server interactiv
199
199
200
200
Instead of an HTML form, submitting a GET request in this scenario could've also used JavaScript to submit the request to the server, either using the [Fetch API](https://developer.mozilla.org/docs/Web/API/Fetch_API)` or [XMLHttpRequest API](https://developer.mozilla.org/docs/Web/API/XMLHttpRequest). In most cases, JavaScript can be replaced by using Blazor and C# in an interactive component.
201
201
202
+
## Style the `QuickGrid` component
203
+
204
+
You can apply styles to the rendered `QuickGrid` component with a stylesheet isolated to the `Index` component using *CSS isolation*.
205
+
206
+
CSS isolation is applied by adding a stylesheet file using the file name format `{COMPONENT NAME}.razor.css`, where the `{COMPONENT NAME}` placeholder is the component name.
207
+
208
+
To apply styles to a child component, such as the `QuickGrid` component of the `Index` component, use the `::deep` pseudo-element.
209
+
210
+
In the `MoviePages` folder, add the following stylesheet for the `Index` component. Use `::deep` pseudo-elements to make the row height `3em` and vertically center the table cell content.
211
+
212
+
`Components/Pages/MoviePages/Index.razor.css`:
213
+
214
+
```css
215
+
::deep tr {
216
+
height: 3em;
217
+
}
218
+
219
+
::deep tr>td {
220
+
vertical-align: middle;
221
+
}
222
+
```
223
+
224
+
The `::deep` pseudo-element only works with descendant elements, so the `QuickGrid` component must be wrapped with a `<div>` or some other block-level element in order to apply the styles to it.
225
+
226
+
In `Components/Pages/MoviePages/Index.razor`, place `<div>` tags around the `QuickGrid` component:
227
+
228
+
```diff
229
+
+ <div>
230
+
<QuickGrid ...>
231
+
...
232
+
</QuickGrid>
233
+
+ </div>
234
+
```
235
+
236
+
Blazor rewrites CSS selectors to match the markup rendered by the component. The rewritten CSS styles are bundled and produced as a static asset, so you don't need to take further action to apply the styles to the rendered `QuickGrid` component.
237
+
238
+

0 commit comments