Skip to content

Commit f41cc97

Browse files
authored
Move Grid column chooser and export demos to their own pages (#1411)
Add Grid > Column Chooser (/demos/grid/column-chooser) and Grid > Export (/demos/grid/export) to both demo menus, move the two demos out of Grid > Other, and point the docs links at the new pages.
1 parent e5e85b2 commit f41cc97

10 files changed

Lines changed: 86 additions & 38 deletions

File tree

‎BlazorBootstrap.Demo.RCL/Components/Layout/DemosMainLayout.razor.cs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,12 @@ internal override IEnumerable<NavItem> GetNavItems()
6161
new (){ Id = "513", Text = "Grid", IconName = IconName.Grid, ParentId = "5" },
6262
new (){ Id = "51301", Text = "Overview", Href = DemoRouteConstants.Demos_URL_Grid_Overview, IconName = IconName.Grid, ParentId = "513" }, // first item - do not change
6363
new (){ Id = "51302", Text = "Alignment", Href = DemoRouteConstants.Demos_URL_Grid_Alignment, IconName = IconName.Justify, ParentId = "513" },
64+
new (){ Id = "51318", Text = "Column Chooser", Href = DemoRouteConstants.Demos_URL_Grid_ColumnChooser, IconName = IconName.ListCheck, ParentId = "513" },
6465
new (){ Id = "51303", Text = "Custom CSS Class", Href = DemoRouteConstants.Demos_URL_Grid_CustomCSSClass, IconName = IconName.FileTypeCss, ParentId = "513" },
6566
new (){ Id = "51304", Text = "Data Binding", Href = DemoRouteConstants.Demos_URL_Grid_DataBinding, IconName = IconName.GridFill, ParentId = "513" },
6667
new (){ Id = "51306", Text = "Detail View", Href = DemoRouteConstants.Demos_URL_Grid_DetailView, IconName = IconName.ListNested, ParentId = "513" },
6768
new (){ Id = "51307", Text = "Events", Href = DemoRouteConstants.Demos_URL_Grid_Events, IconName = IconName.LightningChargeFill, ParentId = "513" },
69+
new (){ Id = "51319", Text = "Export", Href = DemoRouteConstants.Demos_URL_Grid_Export, IconName = IconName.FileEarmarkArrowDown, ParentId = "513" },
6870
new (){ Id = "51317", Text = "Filters", Href = DemoRouteConstants.Demos_URL_Grid_Filters, IconName = IconName.FunnelFill, ParentId = "513" },
6971
new (){ Id = "51308", Text = "Fixed Header", Href = DemoRouteConstants.Demos_URL_Grid_FixedHeader, IconName = IconName.Table, ParentId = "513" },
7072
new (){ Id = "51309", Text = "Freeze Columns", Href = DemoRouteConstants.Demos_URL_Grid_FreezeColumns, IconName = IconName.LayoutThreeColumns, ParentId = "513" },

‎BlazorBootstrap.Demo.RCL/Components/Layout/MainLayout.razor.cs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,12 @@ internal override IEnumerable<NavItem> GetNavItems()
6060
new (){ Id = "513", Text = "Grid", IconName = IconName.Grid, ParentId = "5" },
6161
new (){ Id = "51301", Text = "Overview", Href = DemoRouteConstants.Demos_URL_Grid_Overview, IconName = IconName.Grid, ParentId = "513" }, // first item - do not change
6262
new (){ Id = "51302", Text = "Alignment", Href = DemoRouteConstants.Demos_URL_Grid_Alignment, IconName = IconName.Justify, ParentId = "513" },
63+
new (){ Id = "51318", Text = "Column Chooser", Href = DemoRouteConstants.Demos_URL_Grid_ColumnChooser, IconName = IconName.ListCheck, ParentId = "513" },
6364
new (){ Id = "51303", Text = "Custom CSS Class", Href = DemoRouteConstants.Demos_URL_Grid_CustomCSSClass, IconName = IconName.FileTypeCss, ParentId = "513" },
6465
new (){ Id = "51304", Text = "Data Binding", Href = DemoRouteConstants.Demos_URL_Grid_DataBinding, IconName = IconName.GridFill, ParentId = "513" },
6566
new (){ Id = "51306", Text = "Detail View", Href = DemoRouteConstants.Demos_URL_Grid_DetailView, IconName = IconName.ListNested, ParentId = "513" },
6667
new (){ Id = "51307", Text = "Events", Href = DemoRouteConstants.Demos_URL_Grid_Events, IconName = IconName.LightningChargeFill, ParentId = "513" },
68+
new (){ Id = "51319", Text = "Export", Href = DemoRouteConstants.Demos_URL_Grid_Export, IconName = IconName.FileEarmarkArrowDown, ParentId = "513" },
6769
new (){ Id = "51307", Text = "Filters", Href = DemoRouteConstants.Demos_URL_Grid_Filters, IconName = IconName.FunnelFill, ParentId = "513" },
6870
new (){ Id = "51308", Text = "Fixed Header", Href = DemoRouteConstants.Demos_URL_Grid_FixedHeader, IconName = IconName.Table, ParentId = "513" },
6971
new (){ Id = "51309", Text = "Freeze Columns", Href = DemoRouteConstants.Demos_URL_Grid_FreezeColumns, IconName = IconName.LayoutThreeColumns, ParentId = "513" },
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
@attribute [Route(pageUrl)]
2+
@layout DemosMainLayout
3+
4+
<DemosPageHeadSection PageUrl="@pageUrl"
5+
PageTitle="@pageTitle"
6+
PageDescription="@pageDescription"
7+
MetaTitle="@metaTitle"
8+
MetaDescription="@metaDescription"
9+
ImageUrl="@imageUrl" />
10+
11+
<DocsLink Href="@DemoRouteConstants.Docs_URL_Grid" />
12+
13+
<Section Size="HeadingSize.H2" Name="Column chooser" PageUrl="@pageUrl" Link="column-chooser">
14+
<div class="mb-3">
15+
Let people choose which columns they see and in what order. A <b>Columns</b> button above the grid opens a list with a search box, a checkbox for each column, and move up and move down buttons; columns can also be dragged.
16+
<br />
17+
<strong>How to use:</strong>
18+
<div class="content mb-2">
19+
<ol>
20+
<li>Set <code>AllowColumnChooser="true"</code> on the Grid.</li>
21+
<li>Give each column a <code>PropertyName</code> or <code>HeaderText</code>; the chooser lists the columns by it.</li>
22+
<li>Set <code>AlwaysVisible="true"</code> on a column people must not hide. The last visible column can never be hidden.</li>
23+
<li>To keep the choice, handle <code>GridSettingsChanged</code> and return the saved settings from <code>SettingsProvider</code>. <code>GridSettings.ColumnOrder</code> and <code>GridSettings.HiddenColumns</code> hold it. <b>Reset to default</b>, or <code>ResetColumnsAsync()</code>, restores the declared columns.</li>
24+
</ol>
25+
</div>
26+
Change the text with <code>ColumnChooserButtonText</code>, <code>ColumnChooserSearchPlaceholderText</code>, <code>ColumnChooserResetText</code>, and the other <code>ColumnChooser*Text</code> parameters.
27+
</div>
28+
<Demo Type="typeof(Grid_Demo_01_Column_Chooser)" Tabs="true" />
29+
</Section>
30+
31+
@code {
32+
private const string pageUrl = DemoRouteConstants.Demos_URL_Grid_ColumnChooser;
33+
private const string pageTitle = "Blazor Grid - Column chooser";
34+
private const string pageDescription = "The Blazor Grid component shows tabular data with client-side or server-side paging, sorting and filtering, plus selection, a column chooser, saved settings and CSV export. The example below lets people show, hide and reorder columns, and keeps their choice in saved grid settings.";
35+
private const string metaTitle = "Blazor Grid column chooser example";
36+
private const string metaDescription = "Live Blazor Grid column chooser example with source code: show, hide, search and reorder columns, keep a column always visible, and save the choice in grid settings.";
37+
private const string imageUrl = "https://i.imgur.com/kKNgo2I.png";
38+
}

BlazorBootstrap.Demo.RCL/Components/Pages/Demos/Grid/99-other/Grid_Demo_08_Column_Chooser.razor renamed to BlazorBootstrap.Demo.RCL/Components/Pages/Demos/Grid/17-column-chooser/Grid_Demo_01_Column_Chooser.razor

File renamed without changes.

BlazorBootstrap.Demo.RCL/Components/Pages/Demos/Grid/99-other/Grid_Demo_09_Export_To_Csv.razor renamed to BlazorBootstrap.Demo.RCL/Components/Pages/Demos/Grid/18-export/Grid_Demo_01_Export_To_Csv.razor

File renamed without changes.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
@attribute [Route(pageUrl)]
2+
@layout DemosMainLayout
3+
4+
<DemosPageHeadSection PageUrl="@pageUrl"
5+
PageTitle="@pageTitle"
6+
PageDescription="@pageDescription"
7+
MetaTitle="@metaTitle"
8+
MetaDescription="@metaDescription"
9+
ImageUrl="@imageUrl" />
10+
11+
<DocsLink Href="@DemoRouteConstants.Docs_URL_Grid" />
12+
13+
<Section Size="HeadingSize.H2" Name="Export to CSV" PageUrl="@pageUrl" Link="export-to-csv">
14+
<div class="mb-3">
15+
An <b>Export CSV</b> button downloads every row that matches the current filters and sort, across all pages, with the columns people see, in their order.
16+
<br />
17+
<strong>How to use:</strong>
18+
<div class="content mb-2">
19+
<ol>
20+
<li>Set <code>AllowExport="true"</code> on the Grid, and optionally <code>ExportFileName</code>.</li>
21+
<li>Give each exported column a <code>PropertyName</code>; its value is written with the grid's culture. Set <code>Exportable="false"</code> on columns such as actions.</li>
22+
<li>With a <code>DataProvider</code>, return all matching rows when <code>PageNumber</code> and <code>PageSize</code> are 0. <code>request.ApplyTo(...)</code> already does.</li>
23+
<li>Call <code>ExportToCsvAsync()</code> to export from your own button.</li>
24+
</ol>
25+
</div>
26+
Text that starts with <code>=</code>, <code>+</code>, <code>-</code>, or <code>@@</code> is written with a leading apostrophe, so spreadsheet apps don't run it as a formula.
27+
</div>
28+
<Demo Type="typeof(Grid_Demo_01_Export_To_Csv)" Tabs="true" />
29+
</Section>
30+
31+
@code {
32+
private const string pageUrl = DemoRouteConstants.Demos_URL_Grid_Export;
33+
private const string pageTitle = "Blazor Grid - Export";
34+
private const string pageDescription = "The Blazor Grid component shows tabular data with client-side or server-side paging, sorting and filtering, plus selection, a column chooser, saved settings and CSV export. The example below exports every filtered and sorted row, across all pages, to a CSV file.";
35+
private const string metaTitle = "Blazor Grid export to CSV example";
36+
private const string metaDescription = "Live Blazor Grid export to CSV example with source code: export every filtered and sorted row across all pages, with the visible columns in their order, from the built-in button or your own.";
37+
private const string imageUrl = "https://i.imgur.com/kKNgo2I.png";
38+
}

‎BlazorBootstrap.Demo.RCL/Components/Pages/Demos/Grid/99-other/Grid_Other_Documentation.razor‎

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -41,42 +41,6 @@
4141
<Demo Type="typeof(Grid_Demo_06_Hide_Columns_Dynamically)" Tabs="true" />
4242
</Section>
4343

44-
<Section Size="HeadingSize.H2" Name="Column chooser" PageUrl="@pageUrl" Link="column-chooser">
45-
<div class="mb-3">
46-
Let people choose which columns they see and in what order. A <b>Columns</b> button above the grid opens a list with a search box, a checkbox for each column, and move up and move down buttons; columns can also be dragged.
47-
<br />
48-
<strong>How to use:</strong>
49-
<div class="content mb-2">
50-
<ol>
51-
<li>Set <code>AllowColumnChooser="true"</code> on the Grid.</li>
52-
<li>Give each column a <code>PropertyName</code> or <code>HeaderText</code>; the chooser lists the columns by it.</li>
53-
<li>Set <code>AlwaysVisible="true"</code> on a column people must not hide. The last visible column can never be hidden.</li>
54-
<li>To keep the choice, handle <code>GridSettingsChanged</code> and return the saved settings from <code>SettingsProvider</code>. <code>GridSettings.ColumnOrder</code> and <code>GridSettings.HiddenColumns</code> hold it. <b>Reset to default</b>, or <code>ResetColumnsAsync()</code>, restores the declared columns.</li>
55-
</ol>
56-
</div>
57-
Change the text with <code>ColumnChooserButtonText</code>, <code>ColumnChooserSearchPlaceholderText</code>, <code>ColumnChooserResetText</code>, and the other <code>ColumnChooser*Text</code> parameters.
58-
</div>
59-
<Demo Type="typeof(Grid_Demo_08_Column_Chooser)" Tabs="true" />
60-
</Section>
61-
62-
<Section Size="HeadingSize.H2" Name="Export to CSV" PageUrl="@pageUrl" Link="export-to-csv">
63-
<div class="mb-3">
64-
An <b>Export CSV</b> button downloads every row that matches the current filters and sort, across all pages, with the columns people see, in their order.
65-
<br />
66-
<strong>How to use:</strong>
67-
<div class="content mb-2">
68-
<ol>
69-
<li>Set <code>AllowExport="true"</code> on the Grid, and optionally <code>ExportFileName</code>.</li>
70-
<li>Give each exported column a <code>PropertyName</code>; its value is written with the grid's culture. Set <code>Exportable="false"</code> on columns such as actions.</li>
71-
<li>With a <code>DataProvider</code>, return all matching rows when <code>PageNumber</code> and <code>PageSize</code> are 0. <code>request.ApplyTo(...)</code> already does.</li>
72-
<li>Call <code>ExportToCsvAsync()</code> to export from your own button.</li>
73-
</ol>
74-
</div>
75-
Text that starts with <code>=</code>, <code>+</code>, <code>-</code>, or <code>@@</code> is written with a leading apostrophe, so spreadsheet apps don't run it as a formula.
76-
</div>
77-
<Demo Type="typeof(Grid_Demo_09_Export_To_Csv)" Tabs="true" />
78-
</Section>
79-
8044
<Section Size="HeadingSize.H2" Name="Increase textbox width" PageUrl="@pageUrl" Link="increase-textbox-width">
8145
<Demo Type="typeof(Grid_Demo_07_Increase_TextBox_Width)" Tabs="true" />
8246
</Section>

‎BlazorBootstrap.Demo.RCL/Constants/DemoRouteConstants.cs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,12 @@ public static class DemoRouteConstants
8989
public const string Demos_URL_Grid_Prefix = Demos_URL_Prefix + "/grid";
9090
public const string Demos_URL_Grid_Overview = Demos_URL_Grid_Prefix + "/overview";
9191
public const string Demos_URL_Grid_Alignment = Demos_URL_Grid_Prefix + "/alignment";
92+
public const string Demos_URL_Grid_ColumnChooser = Demos_URL_Grid_Prefix + "/column-chooser";
9293
public const string Demos_URL_Grid_CustomCSSClass = Demos_URL_Grid_Prefix + "/custom-css-class";
9394
public const string Demos_URL_Grid_DataBinding = Demos_URL_Grid_Prefix + "/data-binding";
9495
public const string Demos_URL_Grid_DetailView = Demos_URL_Grid_Prefix + "/detail-view";
9596
public const string Demos_URL_Grid_Events = Demos_URL_Grid_Prefix + "/events";
97+
public const string Demos_URL_Grid_Export = Demos_URL_Grid_Prefix + "/export";
9698
public const string Demos_URL_Grid_Filters = Demos_URL_Grid_Prefix + "/filters";
9799
public const string Demos_URL_Grid_FixedHeader = Demos_URL_Grid_Prefix + "/fixed-header";
98100
public const string Demos_URL_Grid_FreezeColumns = Demos_URL_Grid_Prefix + "/freeze-columns";

‎BlazorBootstrap.Demo.RCL/Constants/DemoScreenshotSrcConstants.cs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,12 @@ public class DemoScreenshotSrcConstants
6161
public const string Demos_URL_Grid_Prefix = DemoScreenshotSrcPrefix + "grid.png";
6262
public const string Demos_URL_Grid_Overview = DemoScreenshotSrcPrefix + "grid_fixed_header_freeze_columns.png";
6363
public const string Demos_URL_Grid_Alignment = DemoScreenshotSrcPrefix + "home.png";
64+
public const string Demos_URL_Grid_ColumnChooser = DemoScreenshotSrcPrefix + "home.png";
6465
public const string Demos_URL_Grid_CustomCSSClass = DemoScreenshotSrcPrefix + "home.png";
6566
public const string Demos_URL_Grid_DataBinding = DemoScreenshotSrcPrefix + "home.png";
6667
public const string Demos_URL_Grid_DetailView = DemoScreenshotSrcPrefix + "home.png";
6768
public const string Demos_URL_Grid_Events = DemoScreenshotSrcPrefix + "home.png";
69+
public const string Demos_URL_Grid_Export = DemoScreenshotSrcPrefix + "home.png";
6870
public const string Demos_URL_Grid_Filters = DemoScreenshotSrcPrefix + "home.png";
6971
public const string Demos_URL_Grid_FixedHeader = DemoScreenshotSrcPrefix + "grid_fixed_header_freeze_columns.png";
7072
public const string Demos_URL_Grid_FreezeColumns = DemoScreenshotSrcPrefix + "grid_fixed_header_freeze_columns.png";

‎docs/docs/05-components/grid.mdx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4562,7 +4562,7 @@ Set `AllowColumnChooser="true"` to show a **Columns** button above the grid. It
45624562
}
45634563
```
45644564

4565-
[See demo here](https://demos.blazorbootstrap.com/demos/grid/other#column-chooser)
4565+
[See demo here](https://demos.blazorbootstrap.com/demos/grid/column-chooser)
45664566

45674567
### Export to CSV
45684568

@@ -4645,4 +4645,4 @@ Text values that start with `=`, `+`, `-`, or `@` are written with a leading apo
46454645
}
46464646
```
46474647

4648-
[See demo here](https://demos.blazorbootstrap.com/demos/grid/other#export-to-csv)
4648+
[See demo here](https://demos.blazorbootstrap.com/demos/grid/export)

0 commit comments

Comments
 (0)