Megabit / Blazorise

Blazorise is a component library built on top of Blazor with support for CSS frameworks like Bootstrap, Tailwind, Bulma, AntDesign, and Material.
https://blazorise.com/
Other
3.3k stars 533 forks source link

[Bug]: DataGridSelectColumn shows filter value instead of empty filter cell #5497

Closed McFSR closed 6 months ago

McFSR commented 6 months ago

Blazorise Version

1.5.2

What Blazorise provider are you running on?

Bootstrap5

Link to minimal reproduction or a simple code snippet

<DataGrid @ref="_dataGrid"
          TItem="BankDTO"
          Data="_bankList"
          Filterable="true">
    <DataGridColumns>
        <DataGridSelectColumn TItem="BankDTO" 
                              Field="@nameof(BankDTO.Rule)" Caption="BankRule" 
                              Data="_allRules" 
                              ValueField="(s) => Convert.ToString(s) " 
                              TextField="(s) => Convert.ToString(s)">
        </DataGridSelectColumn>
    </DataGridColumns>
</DataGrid>

Steps to reproduce

I use the datagrid in the sample above. Data for the select-column ("_allRules") is a list of strings.

What is expected?

  1. When the grid initially renders, the filter in the column "BankRule" is empty and the grid is not filtered.

What is actually happening?

  1. When the grid initially renders, the first value from the _allRules list is displayed in the column filter.
  2. The grid is NOT filtered.
  3. Clicking the clear filter button does NOT clear the filter.

What browsers do you see the problem on?

Chrome

Any additional comments?

No response

David-Moreira commented 6 months ago

@McFSR Does the _allRules list contain an empty value so it can bind to?

If I remember correctly the select component will show the first item if it can't find something to bind to.

McFSR commented 6 months ago

@David-Moreira No _allRules does not have an empty entry. I could do that in this case, but what if I bind an enum to the column? Feels strange I have to provide an empty entry to allow a "not filtered" state.

David-Moreira commented 6 months ago

@McFSR The DataGridSelectColumn is based on our Select component which utilizes html semantics and rules. That's how it works by default the provided <option> is what you get. https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_select image

However, I was just checking, We have an option for a default value in Select (which will generate an extra <option> to accomodate that value)

Can you try using the DefaultItemText and the DefaultItemHidden and see if these fit your needs?

image

McFSR commented 6 months ago

OK, I was able to make it work as desired by simpy adding DefaultItemText="" Thanks!