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.31k stars 533 forks source link

Add FilterTemplate examples to the DataGrid Docs #5612

Open Mr-Pearce opened 4 months ago

Mr-Pearce commented 4 months ago

Currently there is no real example how to use the Filtertemplate. Beneath https://blazorise.com/docs/extensions/datagrid/templates/

Some examples would be helpfull. Also i dont know if it is possible. But binding to the filter from the Filter Template would be nice.

I am currently using the following workaround.

Also is it intended that the Filter on an DataGridDateColumnis an TextBox? Shouldn't it be a DateEditor DateTimePicker?

<DataGridDateColumn Field="@nameof(SomeTime.Timestamp)" InputMode="DateInputMode.DateTime" Caption="Zeitpunkt">
                <FilterTemplate >
                    <DateEdit  TValue="DateTime?" Date="@dateFilter" DateChanged="@OnDateFilterChanged" />
                </FilterTemplate>
            </DataGridDateColumn>

public void OnDateFilterChanged(DateTime? date)
    {
        dateFilter = date;
        var columns = dataGrid.GetColumns().FirstOrDefault(x => x.Field == nameof(SomeTime.Timestamp));

        columns.Filter.SearchValue = date;
        dataGrid.FilterData();
        dataGrid.Reload();
    }

but something like would be nice.

<DataGridDateColumn Field="@nameof(SomeTime.Timestamp)" InputMode="DateInputMode.DateTime" Caption="Zeitpunkt">
                <FilterTemplate >
                    <DateEdit  TValue="DateTime?" bind-Date="@context" />
                </FilterTemplate>
            </DataGridDateColumn>
David-Moreira commented 4 months ago

Hello @Mr-Pearce We have a dedicated page for filtering : https://blazorise.com/docs/extensions/datagrid/features/filtering

This is where we had the FilterTemplate example, but granted nowadays there isn't a concrete example, It seems like we replaced the template example we had on the select column with an actual DataGridSelectColumn.

I think it's worth adding it. But it's usage is like every other template nonethless. (Edit: Altough it might be a bit more involved since you have to explicitly trigger the filtering, so you're right there should be an example.)

image

As for the DateColumn filter, that's coming in v1.6 where we improved the filtering to render more contextual components. (https://github.com/Megabit/Blazorise/pull/5585) You can try it out and give us some feedback prior to the release, if you'd like by using our dev version in myget. https://www.myget.org/gallery/blazorise