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/tutorials/movie-database-app/part-8.md
+38-2Lines changed: 38 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,42 @@ 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 `QuickGrid` rows and cells
203
+
204
+
You can apply table row and cell styles to the rendered `QuickGrid` component with a stylesheet isolated to the `Index` component using *CSS isolation*.
205
+
206
+
CSS isolation only applies to the component you associate with the format `{COMPONENT NAME}.razor.css`, where the `{COMPONENT NAME}` placeholder is the component name. The filename is `Index.razor.css` to apply the isolated styles to the `Index` component.
207
+
208
+
To apply changes to a child component, such as the `QuickGrid` component of the `Index` component, use the `::deep` pseudo-element for element styles in the stylesheet. The `::deep` pseudo-element only works with descendant elements, so the `QuickGrid` component must be wrapped with a `<div>` in order to apply the styles to it.
209
+
210
+
In `Components/Pages/MoviePages/Index.razor`, place `<div>` tags around the `QuickGrid` component:
211
+
212
+
```diff
213
+
+ <div>
214
+
<QuickGrid ...>
215
+
...
216
+
</QuickGrid>
217
+
+ </div>
218
+
```
219
+
220
+
In the `MoviePages` folder, add a new isolated stylesheet for the `Index` component. Use `::deep` pseudo-elements to make the row height `3em` and vertically-center the table cell content.
221
+
222
+
`Components/Pages/MoviePages/Index.razor.css`:
223
+
224
+
```css
225
+
::deep tr {
226
+
height: 3em;
227
+
}
228
+
229
+
::deep tr>td {
230
+
vertical-align: middle;
231
+
}
232
+
```
233
+
234
+
Blazor rewrites CSS selectors to match the markup rendered by the component. The rewritten CSS styles are bundled and produced as a static asset for you, so you don't need to take further action to apply the styles to the `QuickGrid` component when it's rendered.
235
+
236
+

0 commit comments