Skip to content

Commit

Permalink
Merge branch 'master' into 5619-add-multiselection-to-datagrid-select…
Browse files Browse the repository at this point in the history
…column
  • Loading branch information
stsrki committed Nov 25, 2024
2 parents e92889c + ed5935f commit 6ac5b80
Show file tree
Hide file tree
Showing 11 changed files with 106 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dev-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
workflow_dispatch:

env:
BUILD_VERSION: '1.7.0.0'
BUILD_VERSION: '1.8.0.0'

jobs:
build:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<DataGridCommandColumn TItem="Employee"></DataGridCommandColumn>
<DataGridColumn Editable Field="@nameof(Employee.FirstName)" Caption="First Name"></DataGridColumn>
<DataGridNumericColumn Editable Field="@nameof(Employee.Salary)" Caption="Salary"></DataGridNumericColumn>
<DataGridDateColumn DateDisplayFormat="dd.MM.yyyy" DisplayFormat="{0:dd.MM.yyyy}" Editable Field="@nameof(Employee.DateOfBirth)" Caption="Date Of Birth"></DataGridDateColumn>
<DataGridDateColumn DisplayFormat="{0:dd.MM.yyyy}" Editable Field="@nameof(Employee.DateOfBirth)" Caption="Date Of Birth"></DataGridDateColumn>
<DataGridCheckColumn Editable Field="@nameof(Employee.IsActive)" Caption="Active"></DataGridCheckColumn>
<DataGridSelectColumn Caption="Gender" Field="@nameof(Employee.Gender)" Data="EmployeeData.Genders" ValueField="(x) => ((Gender)x).Code" TextField="(x) => ((Gender)x).Description" Editable />
</DataGridColumns>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
Responsive
ShowPager
ShowPageSizes
Groupable>
Groupable
GroupBy="x => x.Gender">
<DataGridColumns>
<DataGridColumn TextAlignment="TextAlignment.Center" TItem="Employee" Field="@nameof( Employee.Id )" Caption="#" Width="60px" />
<DataGridColumn TItem="Employee" Field="@nameof( Employee.FirstName )" Caption="First Name">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</DataGridColumn>
<DataGridDateColumn TItem="Employee" Field="@nameof( Employee.DateOfBirth )" DisplayFormat="{0:dd.MM.yyyy}" Caption="Date Of Birth" Editable />
<DataGridNumericColumn TItem="Employee" Field="@nameof( Employee.Childrens )" Caption="Childrens" Editable Filterable="false" />
<DataGridSelectColumn TItem="Employee" Field="@nameof( Employee.Gender )" Caption="Gender" Editable Data="EmployeeData.Genders" ValueField="(x) => ((Gender)x).Code" TextField="(x) => ((Gender)x).Description" /><DataGridSelectColumn TItem="Employee" Field="@nameof( Employee.Gender )" Caption="Gender" Editable Data="EmployeeData.Genders" ValueField="(x) => ((Gender)x).Code" TextField="(x) => ((Gender)x).Description" />EmployeeData.Genders
<DataGridSelectColumn TItem="Employee" Field="@nameof( Employee.Gender )" Caption="Gender" Editable Data="EmployeeData.Genders" ValueField="(x) => ((Gender)x).Code" TextField="(x) => ((Gender)x).Description" />
<DataGridColumn TItem="Employee" Field="@nameof( Employee.Salary )" Caption="Salary" Editable Width="140px" DisplayFormat="{0:C}" DisplayFormatProvider="@System.Globalization.CultureInfo.GetCultureInfo("fr-FR")" TextAlignment="TextAlignment.End">
</DataGridColumn>
<DataGridCheckColumn TItem="Employee" Field="@nameof(Employee.IsActive)" Caption="Active" Editable Filterable="false">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
</DataGridColumn>
<DataGridDateColumn TItem="Employee" Field="@nameof( Employee.DateOfBirth )" DisplayFormat="{0:dd.MM.yyyy}" Caption="Date Of Birth" Editable />
<DataGridNumericColumn TItem="Employee" Field="@nameof( Employee.Childrens )" Caption="Childrens" Editable Filterable="false" />
<DataGridSelectColumn TItem="Employee" Field="@nameof( Employee.Gender )" Caption="Gender" Editable Data="EmployeeData.Genders" ValueField="(x) => ((Gender)x).Code" TextField="(x) => ((Gender)x).Description" /><DataGridSelectColumn TItem="Employee" Field="@nameof( Employee.Gender )" Caption="Gender" Editable Data="EmployeeData.Genders" ValueField="(x) => ((Gender)x).Code" TextField="(x) => ((Gender)x).Description" />EmployeeData.Genders
<DataGridSelectColumn TItem="Employee" Field="@nameof( Employee.Gender )" Caption="Gender" Editable Data="EmployeeData.Genders" ValueField="(x) => ((Gender)x).Code" TextField="(x) => ((Gender)x).Description" />
<DataGridColumn TItem="Employee" Field="@nameof( Employee.Salary )" Caption="Salary" Editable Width="140px" DisplayFormat="{0:C}" DisplayFormatProvider="@System.Globalization.CultureInfo.GetCultureInfo("fr-FR")" TextAlignment="TextAlignment.End">
</DataGridColumn>
<DataGridCheckColumn TItem="Employee" Field="@nameof(Employee.IsActive)" Caption="Active" Editable Filterable="false">
Expand Down
58 changes: 56 additions & 2 deletions Demos/Blazorise.Demo/Pages/Tests/ListViewPage.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@page "/tests/listview"
@using System.Linq

<Row>
<Column ColumnSize="ColumnSize.IsFull.OnMobile.IsHalf.OnTablet">
Expand All @@ -20,18 +21,71 @@
</CardBody>
</Card>
</Column>
<Column ColumnSize="ColumnSize.IsFull.OnMobile.IsHalf.OnTablet">
<Card Margin="Margin.Is4.OnY">
<CardHeader>
<CardTitle>With custom item content</CardTitle>
</CardHeader>
<CardBody>
<ListView TItem="Country"
Data="Countries"
TextField="(item) => item.Name"
ValueField="(item) => item.Iso"
Mode="ListGroupMode.Static"
MaxHeight="300px">
<ItemTemplate>
<Div Flex="Flex.InlineFlex.JustifyContent.Between" Width="Width.Is100">
<Heading Margin="Margin.Is2.FromBottom">@context.Item.Iso</Heading>
<Small>@context.Item.Capital</Small>
</Div>
<Paragraph Margin="Margin.Is2.FromBottom">@context.Text</Paragraph>
</ItemTemplate>
</ListView>
</CardBody>
</Card>
</Column>
</Row>
<Row>
<Column ColumnSize="ColumnSize.IsFull.OnMobile.IsHalf.OnTablet">
<Card Margin="Margin.Is4.OnY">
<CardHeader>
<CardTitle>Styling Individual Items</CardTitle>
</CardHeader>
<CardBody>
<ListView TItem="Country"
Data="Countries"
TextField="(item) => item.Name"
ValueField="(item) => item.Iso"
Mode="ListGroupMode.Selectable"
MaxHeight="300px"
ItemTextColor="((item) => Countries.IndexOf( item ) % 2 == 0 ? TextColor.Danger : TextColor.Success)"
ItemBackground="(item) => Background.Default"
ItemPadding="(item) => Padding.Is4"
ItemClass="@((item) => $"country-{item.Iso}")"
ItemStyle="@((item) => "border: 1px solid red")"
@bind-SelectedItem="@selectedListViewItem">
</ListView>

<Field Horizontal>
<FieldBody ColumnSize="ColumnSize.Is12">
Selected Item: @selectedListViewItem?.Name
</FieldBody>
</Field>
</CardBody>
</Card>
</Column>
</Row>

@code {
[Inject]
public CountryData CountryData { get; set; }
public IEnumerable<Country> Countries;
public List<Country> Countries;

private Country selectedListViewItem { get; set; }

protected override async Task OnInitializedAsync()
{
Countries = await CountryData.GetDataAsync();
Countries = (await CountryData.GetDataAsync()).ToList();
await base.OnInitializedAsync();
}
}
30 changes: 28 additions & 2 deletions Demos/Blazorise.Demo/Pages/Tests/SelectListPage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,33 @@
</CardBody>
</Card>
</Column>
<Column ColumnSize="ColumnSize.IsFull.OnMobile.IsHalf.OnTablet">
<Card Margin="Margin.Is4.OnY">
<CardHeader>
<CardTitle>With Multiple Selections</CardTitle>
</CardHeader>
<CardBody>
<Field Horizontal JustifyContent="JustifyContent.End">
<FieldLabel ColumnSize="ColumnSize.Is2">Select Value</FieldLabel>
<FieldBody ColumnSize="ColumnSize.Is10">
<SelectList TItem="Country"
TValue="string"
Data="@Countries"
TextField="@(( item ) => item.Name)"
ValueField="@((item) => item.Iso)"
Multiple
@bind-SelectedValues="@selectedListValues"
DefaultItemText="Choose your country(s)" />
</FieldBody>
</Field>
<Field Horizontal JustifyContent="JustifyContent.End">
<FieldBody ColumnSize="ColumnSize.Is10.Is2.WithOffset">
Selected value(s): @(selectedListValues != null ? string.Join( ',', selectedListValues ) : "")
</FieldBody>
</Field>
</CardBody>
</Card>
</Column>
</Row>

@code {
Expand All @@ -36,12 +63,11 @@
public IEnumerable<Country> Countries;

private string selectedListValue { get; set; }
IReadOnlyList<string> selectedListValues { get; set; }

protected override async Task OnInitializedAsync()
{
Countries = await CountryData.GetDataAsync();
await base.OnInitializedAsync();
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static class CssProvidersService
{ CssProvider.Material, new ProviderData("materialdemo", "material.svg", "Material image", "Material", "material") },
{ CssProvider.AntDesign, new ProviderData("antdesigndemo", "ant-design.svg", "AntDesign image", "Ant Design", "ant-design") },
{ CssProvider.Bulma, new ProviderData("bulmademo", "bulma.svg", "Bulma image", "Bulma", "bulma") },
{ CssProvider.FluentUi2, new ProviderData("fluentuidemo", "fluent2.svg", "Fluent 2 image", "Fluent 2", "fluentui") }
{ CssProvider.FluentUi2, new ProviderData("fluentui2demo", "fluent2.svg", "Fluent 2 image", "Fluent 2", "fluent2") }
};

public static ProviderData GetProvider( CssProvider provider ) => ProvidersData.TryGetValue( provider, out var data )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@ public SelectItem( string text, object value, bool disabled )
protected override void OnInitialized()
{
elementId = IdGenerator.Generate;
base.OnInitialized();
}

if ( Column.Data is not null )
protected override void OnParametersSet()
{
if ( Column?.Data is not null && selectItems?.Count != Column.Data.Count() )
{
selectItems = new();
foreach ( var item in Column.Data )
Expand All @@ -55,8 +59,7 @@ protected override void OnInitialized()
selectItems.Add( new( text, value, disabled ) );
}
}

base.OnInitialized();
base.OnParametersSet();
}

private void OnSelectedValueChanged( object value )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ protected bool HasCommandColumn
=> Columns.Any( x => x.ColumnType == DataGridColumnType.Command );

protected int ColumnSpan
=> Columns.Count - ( HasCommandColumn && !ParentDataGrid.Editable ? 1 : 0 );
=> Columns.Where( x => x.Displayable ).Count() - ( HasCommandColumn && !ParentDataGrid.Editable ? 1 : 0 );

/// <summary>
/// Item associated with the data set.
Expand Down
8 changes: 8 additions & 0 deletions signatures/version1/cla.json
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,14 @@
"created_at": "2024-11-04T12:33:29Z",
"repoId": 159973917,
"pullRequestNo": 5819
},
{
"name": "brauerj-gc",
"id": 126491934,
"comment_id": 2489376053,
"created_at": "2024-11-20T19:23:47Z",
"repoId": 159973917,
"pullRequestNo": 5863
}
]
}

0 comments on commit 6ac5b80

Please sign in to comment.