Skip to content

Commit

Permalink
Merge branch 'rel-1.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
stsrki committed Nov 25, 2024
2 parents 5108fd7 + 066e0f7 commit ed5935f
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 15 deletions.
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();
}


}
1 change: 0 additions & 1 deletion Documentation/Blazorise.Docs/NewFilesToBuild.txt
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
D:\Projects\UI\Blazorise\Documentation\Blazorise.Docs\Pages\Docs\Extensions\DataGrid\Code\DataGridSortComparerExampleCode.html
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 @@ -22,6 +22,7 @@ private class SelectItem
public string Text { get; private set; }
public object Value { get; private set; }
public bool Disabled { get; private set; }

public SelectItem( string text, object value, bool disabled )
{
Text = text;
Expand All @@ -39,8 +40,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 @@ -51,8 +56,7 @@ protected override void OnInitialized()
selectItems.Add( new( text, value, disabled ) );
}
}

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

private void OnSelectedValueChanged( object value )
Expand Down Expand Up @@ -92,7 +96,6 @@ protected override async Task OnAfterRenderAsync( bool firstRender )
{
await Focus();
}

}
}
await base.OnAfterRenderAsync( firstRender );
Expand All @@ -115,6 +118,7 @@ public async Task Select()
[CascadingParameter] public DataGrid<TItem> ParentDataGrid { get; set; }

[Inject] public IIdGenerator IdGenerator { get; set; }

/// <summary>
/// Gets or sets the <see cref="IJSUtilitiesModule"/> instance.
/// </summary>
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

0 comments on commit ed5935f

Please sign in to comment.