Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
McFSR opened this issue May 7, 2024 · 4 comments
Closed
Assignees
Labels
Type: Bug 🐞 Something isn't working

Comments

@McFSR
Copy link

McFSR commented May 7, 2024

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

@McFSR McFSR added the Type: Bug 🐞 Something isn't working label May 7, 2024
@David-Moreira
Copy link
Contributor

@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
Copy link
Author

McFSR commented May 7, 2024

@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
Copy link
Contributor

@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
Copy link
Author

McFSR commented May 7, 2024

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

@McFSR McFSR closed this as completed May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug 🐞 Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants