MudBlazor icon indicating copy to clipboard operation
MudBlazor copied to clipboard

O nome de tipo ou namespace "Examples" não existe no namespace "MudBlazor"

Open MatheusHenriqueCorrea opened this issue 1 year ago • 2 comments

Bug type

Docs (mudblazor.com)

Component name

No response

What happened?

Estou com este problema Gravidade Código Descrição Projeto Arquivo Linha Estado de Supressão Erro CS0234 O nome de tipo ou namespace "Examples" não existe no namespace "MudBlazor" (você está sem uma referência de assembly?) HQZ.UI.Web E:\ Integrador\OrcamentoWeb\src\HQZ.UI.Web\Pages\Estoque\Estoque.razor 104 Ativo

Expected behavior

exemplos sejam reconhecidos e utilizáveis.

Reproduction link

https://try.mudblazor.com/snippet/caQIOQcFpRKQqTIU

Reproduction steps

  1. Realiza a importação e intalação dos pacotes
  2. Adicione exemplo de DataGrid no código que contenha a diretiva @using MudBlazor.Examples.Data.Models
  3. Rodar programa
  4. Ocorreu um erro ...

Relevant log output

@using System.Net.Http.Json
@using MudBlazor.Examples.Data.Models
@inject HttpClient httpClient

<MudDataGrid T="Element" MultiSelection="true" Items="@Elements" SortMode="SortMode.Multiple" Filterable="true" QuickFilter="@_quickFilter"
    Hideable="true" RowClick="@RowClicked" RowContextMenuClick="RowRightClicked" SelectedItemsChanged="@SelectedItemsChanged">
    <ToolBarContent>
        <MudText Typo="Typo.h6">Periodic Elements</MudText>
        <MudSpacer />
        <MudTextField @bind-Value="_searchString" Placeholder="Search" Adornment="Adornment.Start" Immediate="true"
            AdornmentIcon="@Icons.Material.Filled.Search" IconSize="Size.Medium" Class="mt-0"></MudTextField>
    </ToolBarContent>
    <Columns>
        <SelectColumn T="Element" />
        <PropertyColumn Property="x => x.Number" Title="Nr" Sortable="false" Filterable="false" />
        <PropertyColumn Property="x => x.Sign" />
        <PropertyColumn Property="x => x.Name" SortBy="@_sortBy" />
        <PropertyColumn Property="x => x.Position" />
        <PropertyColumn Property="x => x.Molar" Title="Molar mass" />
        <PropertyColumn Property="x => x.Group" Title="Category" />
    </Columns>
    <PagerContent>
        <MudDataGridPager T="Element" />
    </PagerContent>
</MudDataGrid>

<div class="d-flex flex-wrap mt-4">
    <MudSwitch @bind-Checked="@_sortNameByLength" Color="Color.Primary">Sort Name Column By Length</MudSwitch>
</div>

<MudExpansionPanels Style="flex:1">
    <MudExpansionPanel Text="Show Events">
        @foreach (var message in _events)
        {
            <MudText Typo="@Typo.body2">@message</MudText>
        }
        @if(_events.Count > 0) 
        {
            <div class="d-flex">
                <MudSpacer/>
                <MudButton Class="mt-3" ButtonType="ButtonType.Button" Variant="Variant.Filled" OnClick="@(() => _events.Clear())">Clear</MudButton>
            </div>
        }
    </MudExpansionPanel>
</MudExpansionPanels>

@code {
    private IEnumerable<Element> Elements = new List<Element>();
    private string _searchString;
    private bool _sortNameByLength;
    private List<string> _events = new();
    // custom sort by name length
    private Func<Element, object> _sortBy => x =>
    {
        if (_sortNameByLength)
            return x.Name.Length;
        else
            return x.Name;
    };
    // quick filter - filter globally across multiple columns with the same input
    private Func<Element, bool> _quickFilter => x =>
    {
        if (string.IsNullOrWhiteSpace(_searchString))
            return true;

        if (x.Sign.Contains(_searchString, StringComparison.OrdinalIgnoreCase))
            return true;

        if (x.Name.Contains(_searchString, StringComparison.OrdinalIgnoreCase))
            return true;

        if ($"{x.Number} {x.Position} {x.Molar}".Contains(_searchString))
            return true;

        return false;
    };

    protected override async Task OnInitializedAsync()
    {
        Elements = await httpClient.GetFromJsonAsync<List<Element>>("webapi/periodictable");
    }

    // events
    void RowClicked(DataGridRowClickEventArgs<Element> args)
    {
        _events.Insert(0, $"Event = RowClick, Index = {args.RowIndex}, Data = {System.Text.Json.JsonSerializer.Serialize(args.Item)}");
    }
    
    void RowRightClicked(DataGridRowClickEventArgs<Element> args)
    {
        _events.Insert(0, $"Event = RowRightClick, Index = {args.RowIndex}, Data = {System.Text.Json.JsonSerializer.Serialize(args.Item)}");
    }

    void SelectedItemsChanged(HashSet<Element> items)
    {
        _events.Insert(0, $"Event = SelectedItemsChanged, Data = {System.Text.Json.JsonSerializer.Serialize(items)}");
    }
}

Gravidade Código Descrição Projeto Arquivo Linha Estado de Supressão Erro CS0234 O nome de tipo ou namespace "Examples" não existe no namespace "MudBlazor" (você está sem uma referência de assembly?) HQZ.UI.Web E:\Integrador\OrcamentoWeb\src\HQZ.UI.Web\Pages\Estoque\Estoque.razor 104 Ativo

Version (bug)

6.15.0

Version (working)

No response

What browsers are you seeing the problem on?

Microsoft Edge

On what operating system are you experiencing the issue?

Other

Pull Request

  • [ ] I would like to do a Pull Request

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

MatheusHenriqueCorrea avatar Feb 21 '24 14:02 MatheusHenriqueCorrea

Reproduction steps Import and install packages Add a DataGrid example to the code that contains the directive@using MudBlazor.Examples.Data.Models Roll program An error has occurred

what packages did you install? The examples are not part of the MudBlazor package, they are meant for use in the Docs (webpage) as can be seen by the reference here. The MudBlazor package has no such reference.

Anu6is avatar Feb 21 '24 21:02 Anu6is

At first I thought that author means that when you click "run" of the example https://mudblazor.com/components/datagrid#advanced-data-grid the "Example" object is not included (this happened in past), but so far I see it's on place. As @Anu6is said the "Example" class is not part of MudBlazor core library, you need to create it explicitly yourself if you want to try it in your project.

ScarletKuro avatar Feb 21 '24 23:02 ScarletKuro

Closing, since no feedback from author.

ScarletKuro avatar Mar 10 '24 19:03 ScarletKuro