Skip to content

Commit

Permalink
Adds InitialSorted to ColumnBase.razor.cs. This allows user to set wh…
Browse files Browse the repository at this point in the history
…at column is sorted if any by default.
  • Loading branch information
jbomhold3 committed Oct 22, 2024
1 parent fe9230c commit ead0913
Show file tree
Hide file tree
Showing 40 changed files with 34 additions and 17 deletions.
Binary file modified docs/VNext/_framework/BlazorStrap.Docs.wasm
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.Docs.wasm.br
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.Docs.wasm.gz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.Extensions.TreeView.wasm
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.Extensions.TreeView.wasm.br
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.Extensions.TreeView.wasm.gz
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.Extensions.Wizard.wasm
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.Extensions.Wizard.wasm.br
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.Extensions.Wizard.wasm.gz
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.V4.wasm
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.V4.wasm.br
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.V4.wasm.gz
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.V5.wasm
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.V5.wasm.br
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.V5.wasm.gz
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.WASM.wasm
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.WASM.wasm.br
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.WASM.wasm.gz
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.wasm
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.wasm.br
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.wasm.gz
Binary file not shown.
18 changes: 9 additions & 9 deletions docs/VNext/_framework/blazor.boot.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"mainAssemblyName": "BlazorStrap.WASM",
"resources": {
"hash": "sha256-i4nRCgSJEIU/mhctcuZFCbykLQeOiXUYUX5hfheZlsE=",
"hash": "sha256-BAcV6XhcFpcDDXmQLer3bGkeRFE1P/MpThbYYBpWGAs=",
"jsModuleNative": {
"dotnet.native.js": "sha256-QVxMlY7ohmjgde/bZMA0dlWDAeuUP+tEfkiSdg4DFcE="
},
Expand All @@ -19,14 +19,14 @@
"coreAssembly": {},
"assembly": {
"BlazorComponentUtilities.wasm": "sha256-7qa+C6Zt8hJgUpiGcE1MHWuwfOGMUMVd8ayItqmtQp0=",
"BlazorStrap.Docs.wasm": "sha256-xws9a6Z58PFWV43FpGtdoi3oAKKdki3tP+EaIFxkr3g=",
"BlazorStrap.Extensions.FluentValidation.wasm": "sha256-ls3U6Aa2rwVZcQhGsDi3n1YPnT3Z0PRQsLv23E8b+iI=",
"BlazorStrap.Extensions.TreeView.wasm": "sha256-B0O0a/c8Md3B9+qj/MioWWmaM9HigmMHHe7hJEHF2ZA=",
"BlazorStrap.Extensions.Wizard.wasm": "sha256-H5u9OB050Or4gYEFeTmf4fKWFHz5Nti+cVxW3cWNry8=",
"BlazorStrap.V4.wasm": "sha256-bP+5Ba67DG8hsEcTf8oeacT1CX+oFwRRjQMPUXcZJxs=",
"BlazorStrap.V5.wasm": "sha256-SMpLih3V04+kzpI7W9yRxcDJciLGPQtSOQxhdP2/heQ=",
"BlazorStrap.wasm": "sha256-gWDifRMmOYXI64j7OsQifMK6aHY6KRaghfTAEGlEvN8=",
"BlazorStrap.WASM.wasm": "sha256-0mYn8a8+K7e39Zm+xSvJSDGW0Wyvtsuinga3JYGN4Po=",
"BlazorStrap.Docs.wasm": "sha256-/LE7U0vEsPcjSBX3Rd3Z465KypKG1Z0lfR7D5wJ8ohY=",
"BlazorStrap.Extensions.FluentValidation.wasm": "sha256-pUXiL3EM66maAnTMl+/Aq8bwWAJC+OoQGyw1kCtazZ4=",
"BlazorStrap.Extensions.TreeView.wasm": "sha256-Rj1MkpviqwCTSJGmk4rP79ImcEmDoA40z9KanBZOjNQ=",
"BlazorStrap.Extensions.Wizard.wasm": "sha256-Mly6SNewt/vOE4pOUXYj9i+rf8HgzU3UnqjH3K6mt2Y=",
"BlazorStrap.V4.wasm": "sha256-77bWwaasM5hcJmgDqJ1+a7tYdBJBlmrlJj0BkJUUVFs=",
"BlazorStrap.V5.wasm": "sha256-jCy3kcoo0AR6BiLgSfLwDj4pORsoLuTvzsmRllRD72s=",
"BlazorStrap.wasm": "sha256-ZEt+U0OwPQzUML6+NDG93FoL9DuRvrAUTJxNrojhHKY=",
"BlazorStrap.WASM.wasm": "sha256-cRgE8DzXB8t9XoQyr+r/PpB9sZQ8SlRCgLdKRpMuwCE=",
"ColorCode.wasm": "sha256-Mz8W+iFHEtIXuTOac2VcI5RUaHwtcUTIC2fBfuvodVE=",
"FluentValidation.wasm": "sha256-FvsjqyJeVfoCs1v2ywx3Q1mEKXXI4uKcTOdMF+cAH98=",
"Markdig.SyntaxHighlighting.wasm": "sha256-X826lDfQCYyN/vrEQxxfipczU0w7acPz0NyOCyk45yg=",
Expand Down
Binary file modified docs/VNext/_framework/blazor.boot.json.br
Binary file not shown.
Binary file modified docs/VNext/_framework/blazor.boot.json.gz
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<div>
<BSDataGrid IsStriped="true" IsSmall="true" Items="_employees.AsQueryable()" IsMultiSort="true" @ref="_dataGrid" Pagination="_pagination" IsVirtualized="true">
<Columns>
<TemplateColumn IsSortable="true" Property="employee => employee.Id" Title="Id">
<TemplateColumn IsSortable="true" Property="employee => employee.Id" Title="Id" InitialSorted="true">
<Content>@context.Id</Content>
</TemplateColumn>
<PropertyColumn Property="e => e.NameObject.FirstName" IsSortable="true"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<div>
<BSDataGrid IsStriped="true" IsSmall="true" Items="_employees.AsQueryable()" IsMultiSort="true" @ref="_dataGrid" Pagination="_pagination" IsVirtualized="true">
<Columns>
<TemplateColumn IsSortable="true" Property="employee => employee.Id" Title="Id">
<TemplateColumn IsSortable="true" Property="employee => employee.Id" Title="Id" InitialSorted="true">
<Content>@context.Id</Content>
</TemplateColumn>
<PropertyColumn Property="e => e.NameObject.FirstName" IsSortable="true"/>
Expand Down
1 change: 1 addition & 0 deletions docs/VNext/docs/Static/V4/Components/Datagrid.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ See [Tables](V4/content/tables) for additional parameters
| IsFilterable | bool | true/false | Enables filtering on the column |
| Title | string | string | Title of the column |
| CustomSort | Func<SortData<TGridItem>, SortData<TGridItem>> | Func<SortData<TGridItem>, SortData<TGridItem>> | Custom sort function |
| InitialSorted | bool | true/false | Initial sorted column. Only one is valid |
| InitialSortDescending | bool | true/false | Initial sort direction |
| Class | string | string | Class for the column |
| Style | string | string | Style for the column |
Expand Down
1 change: 1 addition & 0 deletions docs/VNext/docs/Static/V5/Components/Datagrid.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ See [Tables](V5/content/tables) for additional parameters
| IsFilterable | bool | true/false | Enables filtering on the column |
| Title | string | string | Title of the column |
| CustomSort | Func<SortData<TGridItem>, SortData<TGridItem>> | Func<SortData<TGridItem>, SortData<TGridItem>> | Custom sort function |
| InitialSorted | bool | true/false | Initial sorted column. Only one is valid |
| InitialSortDescending | bool | true/false | Initial sort direction |
| Class | string | string | Class for the column |
| Style | string | string | Style for the column |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<div>
<BSDataGrid IsStriped="true" IsSmall="true" Items="_employees.AsQueryable()" IsMultiSort="true" @ref="_dataGrid" Pagination="_pagination" IsVirtualized="true">
<Columns>
<TemplateColumn IsSortable="true" Property="employee => employee.Id" Title="Id">
<TemplateColumn IsSortable="true" Property="employee => employee.Id" Title="Id" InitialSorted="true">
<Content>@context.Id</Content>
</TemplateColumn>
<PropertyColumn Property="e => e.NameObject.FirstName" IsSortable="true"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<div>
<BSDataGrid IsStriped="true" IsSmall="true" Items="_employees.AsQueryable()" IsMultiSort="true" @ref="_dataGrid" Pagination="_pagination" IsVirtualized="true">
<Columns>
<TemplateColumn IsSortable="true" Property="employee => employee.Id" Title="Id">
<TemplateColumn IsSortable="true" Property="employee => employee.Id" Title="Id" InitialSorted="true">
<Content>@context.Id</Content>
</TemplateColumn>
<PropertyColumn Property="e => e.NameObject.FirstName" IsSortable="true"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<div>
<BSDataGrid IsStriped="true" IsSmall="true" Items="_employees.AsQueryable()" IsMultiSort="true" @ref="_dataGrid" Pagination="_pagination" IsVirtualized="true">
<Columns>
<TemplateColumn IsSortable="true" Property="employee => employee.Id" Title="Id">
<TemplateColumn IsSortable="true" Property="employee => employee.Id" Title="Id" InitialSorted="true">
<Content>@context.Id</Content>
</TemplateColumn>
<PropertyColumn Property="e => e.NameObject.FirstName" IsSortable="true"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<div>
<BSDataGrid IsStriped="true" IsSmall="true" Items="_employees.AsQueryable()" IsMultiSort="true" @ref="_dataGrid" Pagination="_pagination" IsVirtualized="true">
<Columns>
<TemplateColumn IsSortable="true" Property="employee => employee.Id" Title="Id">
<TemplateColumn IsSortable="true" Property="employee => employee.Id" Title="Id" InitialSorted="true">
<Content>@context.Id</Content>
</TemplateColumn>
<PropertyColumn Property="e => e.NameObject.FirstName" IsSortable="true"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ See [Tables](V4/content/tables) for additional parameters
| IsFilterable | bool | true/false | Enables filtering on the column |
| Title | string | string | Title of the column |
| CustomSort | Func<SortData<TGridItem>, SortData<TGridItem>> | Func<SortData<TGridItem>, SortData<TGridItem>> | Custom sort function |
| InitialSorted | bool | true/false | Initial sorted column. Only one is valid |
| InitialSortDescending | bool | true/false | Initial sort direction |
| Class | string | string | Class for the column |
| Style | string | string | Style for the column |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ See [Tables](V5/content/tables) for additional parameters
| IsFilterable | bool | true/false | Enables filtering on the column |
| Title | string | string | Title of the column |
| CustomSort | Func<SortData<TGridItem>, SortData<TGridItem>> | Func<SortData<TGridItem>, SortData<TGridItem>> | Custom sort function |
| InitialSorted | bool | true/false | Initial sorted column. Only one is valid |
| InitialSortDescending | bool | true/false | Initial sort direction |
| Class | string | string | Class for the column |
| Style | string | string | Style for the column |
Expand Down
2 changes: 1 addition & 1 deletion src/BlazorStrap/BlazorStrap.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<PackageProjectUrl>https://blazorstrap.io/</PackageProjectUrl>
<RepositoryUrl>https://github.com/chanan/BlazorStrap</RepositoryUrl>
<RootNamespace>BlazorStrap</RootNamespace>
<PackageVersion>5.2.103-RC1a</PackageVersion>
<PackageVersion>5.2.103-RC2</PackageVersion>
<AnalysisLevel>6.0</AnalysisLevel><!--Next Use 5.2.200-Preview1-->
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public abstract partial class ColumnBase<TGridItem> : ComponentBase, IDisposable
[Parameter] public bool IsSortable { get; set; }
[Parameter] public string? Title { get; set; }
[Parameter] public Func<SortData<TGridItem>, SortData<TGridItem>>? CustomSort { get; set; }
[Parameter] public bool InitialSorted { get; set; }
[Parameter] public bool InitialSortDescending { get; set; } = false;
[Parameter] public string? Class { get; set; } = string.Empty;
[Parameter] public string? Style { get; set; } = string.Empty;
Expand All @@ -27,6 +28,7 @@ public abstract partial class ColumnBase<TGridItem> : ComponentBase, IDisposable

[Parameter] public bool IsFilterable { get; set; }
[Parameter] public int MaxTextWidth { get; set; }

public virtual RenderFragment<IColumnHeaderAccessor>? ColumnOptions { get; set; }
public int SortOrder { get; set; }
public IColumnHeaderAccessor? ColumnHeaderAccessor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,18 @@ public void AddColumn(ColumnBase<TGridItem> column)
if(_columns.Any(x => x.Id == column.Id)) return;
if (column.IsSortable || column.CustomSort != null)
{
_sortColumns.Add(new SortColumn<TGridItem>(column.Id, false, _sortColumns.Count, false, column.PropertyPath, column));
var sortColumn = new SortColumn<TGridItem>(column.Id, false, _sortColumns.Count, false, column.PropertyPath, column);
_sortColumns.Add(sortColumn);

// Assigns the initial sort column based on Parameter only one column can be initially sorted
if (column.InitialSorted)
{
foreach (var otherColumns in (_sortColumns.Where(x => x.Column.IsSortable)))
{
otherColumns.Sorted = false;
}
sortColumn.Sorted = true;
}
}
_columns.Add(column);
}
Expand Down

0 comments on commit ead0913

Please sign in to comment.