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] Filter on DateTime column not working #352

Open
YongQuan-dotnet opened this issue Sep 4, 2021 · 2 comments
Open

[Bug] Filter on DateTime column not working #352

YongQuan-dotnet opened this issue Sep 4, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@YongQuan-dotnet
Copy link

YongQuan-dotnet commented Sep 4, 2021

Describe the bug
Filtering on DateTime column does not work. I have also directly run the repo in local, and found the Filtering on DateTime does not work either.

To Reproduce
to create a simple page can reproduce

@page "/test"
@using BlazorTable
<div>
    <Table TableItem="TestData" Items="TestDatas" PageSize="10">
        <Column TableItem="TestData" Title="Id" Field="@(x => x.Id)" Sortable="true" Filterable="true" Width="auto" />
        <Column TableItem="TestData" Title="Event DateTime" Field="@(x => x.EventDate)" Sortable="true" Filterable="true" Width="auto">
		</Column>
    </Table>
</div>

@code {     
    public List<TestData> TestDatas { get; set; } = new List<TestData>
    {
        new TestData {Id = 1, EventDate = DateTime.Now },
        new TestData {Id = 2, EventDate = DateTime.Now.AddDays(1)},
        new TestData {Id = 3, EventDate = DateTime.Now.AddDays(2)},
        new TestData {Id = 4, EventDate = DateTime.Now.AddDays(3)},
        new TestData {Id = 5, EventDate = DateTime.Now.AddDays(4)},
        new TestData {Id = 6, EventDate = DateTime.Now.AddDays(5)}
    };

    public class TestData
    {
        public int Id { get; set; }
        public DateTime EventDate { get; set; }
    }
}

Expected behavior
filtering on DateTime column can work

@YongQuan-dotnet YongQuan-dotnet added the bug Something isn't working label Sep 4, 2021
@conficient
Copy link
Collaborator

Having a look at this.

The filter for dates does work provided the value is exact:
image

..or if you used a Greater Than or Less Than this does work:
image

In your sample you're using a DateTime value with a time element. In this case a value of 2021-09-12T15:16:00Z won't be equal to 2021-09-21T00:00:00Z - these are not the equal.

I assume you'd like a date "Is Equal To" to apply a range, e.g. >= 2021-09-12 && < 2021-09-13 ?

I'd need to discuss with @IvanJosipovic to see if that is a good idea.

@skyfrog4fun
Copy link

Extending the example of @JamesGit-hash with DateTime?, I noticed that the filter is not properly working.

Having the simple page

@page "/test"
@using BlazorTable

<div>
    <Table TableItem="TestData" Items="TestDatas" PageSize="10">
        <Column TableItem="TestData" Title="Id" Field="@(x => x.Id)" Sortable="true" Filterable="true" Width="auto" />
        <Column TableItem="TestData" Title="Event DateTime" Field="@(x => x.EventDate)" Sortable="true" Filterable="true" Width="auto">
		</Column>
    </Table>
</div>

@code {     
    public List<TestData> TestDatas { get; set; } = new List<TestData>
    {
        new TestData {Id = 1, EventDate = DateTime.Now },
        new TestData {Id = 2, EventDate = DateTime.Now.AddDays(1)},
        new TestData {Id = 3, EventDate = DateTime.Now.AddDays(2)},
        new TestData {Id = 4, EventDate = DateTime.Now.AddDays(3)},
        new TestData {Id = 5, EventDate = DateTime.Now.AddDays(4)},
        new TestData {Id = 6, EventDate = DateTime.Now.AddDays(5)},
        new TestData {Id = 7, EventDate = null},
    };

    public class TestData
    {
        public int Id { get; set; }
        public DateTime? EventDate { get; set; }
    }
}

When filtering for "Is not null" everything seems to be good.
GitHub_Bug352_IsNotNull

But, when going to filter the events not having a date set, event with id 7 cannot be found.
GitHub_Bug352_IsNull

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants