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

Independent command #1914

Closed
Wolfenry opened this issue Feb 24, 2021 · 6 comments
Closed

Independent command #1914

Wolfenry opened this issue Feb 24, 2021 · 6 comments

Comments

@Wolfenry
Copy link

I'm trying to have a custom clear filter command in the filtertemplate section (the broom in picture below), since i don't want a new column to clear all the filters (the command column).

_DataGridClearFilterCommand depends on the command column and click eventhandler, so i can't make my own clear button easily

I've tried:

<DataGridCheckColumn TItem="Aitem" Field="@nameof(Aitem._chk)" Filterable="true">
    <FilterTemplate>
        <Icon Name="@("fa-broom")"  @onmousedown="@(e => clear = true)"/>
    </FilterTemplate>
    <DisplayTemplate>
        <Check Inline="true" TValue="bool" @bind-Checked="@context._chk" />
    </DisplayTemplate>
</DataGridCheckColumn>

and trigger the ClearFilter event with my 'clear' boolean but had no luck, is there any way to do this?

image

@David-Moreira
Copy link
Contributor

@stsrki one more case about exposing the internal API, right? I think we should get on this soon.

@Wolfenry as a dirty and hopefully ONLY TEMPORARY workaround you could hide the button and invoke it either by using a reference and calling it in c# or by giving it an id and by using javascript.
Since you don't want the command column to be showing up. You could use the API thats exposed in the ButtonRowTemplate:

  <ButtonRowTemplate>
          <Button hidden id="triggerThisFromJavascript" @ref="orTriggerThisFromC#" Color="Color.Link" Clicked="@context.ClearFilterCommand.Clicked">Clear Filter</Button>
  </ButtonRowTemplate>

I haven't tested it, but pretty sure it should work as a workaround. Let me know the results if you try it!

@David-Moreira
Copy link
Contributor

I was testing something else, and ended up testing this workaround, the c# version, it works:
Full code:

<DataGrid Data="Data"
          TItem="Test"
          ShowPager="true"
          Filterable="true">
    <EmptyTemplate>No records... :(</EmptyTemplate>
    <DataGridColumns>
        <DataGridColumn TItem="Test" Field="@nameof(Test.name)" Caption="Testing">
        </DataGridColumn>
    </DataGridColumns>
    <ButtonRowTemplate>
        <Blazorise.Button @ref="@HiddenClearFilterButton" hidden Clicked="@context.ClearFilterCommand.Clicked"  ></Blazorise.Button>
    </ButtonRowTemplate>
</DataGrid>


<button @onclick="Clear">CLEAR!</button>

@code{
    public Blazorise.Button HiddenClearFilterButton { get; set; }

    private Task Clear()
    {
       return HiddenClearFilterButton.Clicked.InvokeAsync();
    }

    public List<Test> EmptyData { get; set; } = new List<Test>();
    public List<Test> Data { get; set; } = new List<Test>() { new Test() { name = "1" } };

    public class Test
    {
        public string name { get; set; }
    }

}

captured

@Wolfenry
Copy link
Author

Wolfenry commented Feb 25, 2021

Great, i tried something like this but i still have the same problem (accesing ClearFilter )

Can't find <ButtonRowTemplate> component:
image

Maybe i am missing something, just tell me!

Also with the actual ClearFilter found a bug on resetting <FilterTemplate> (just the text, not the value)
To reproduce in https://bootstrapdemo.blazorise.com/tests/datagrid: Change value con filter combo box > click on Clear Filter.

@David-Moreira
Copy link
Contributor

Sorry! ButtonRow is a new feature coming in 0.9.3 sometimes I just forget not everyone is using the pre-releases. :P
Anyway should be coming out soon, if you'd like to upgrade. @stsrki still end of week, right?

For another temporary workaround, but compatible with 0.9.2, the one posted on #1915 by @kswoll should work.

To reproduce in https://bootstrapdemo.blazorise.com/tests/datagrid: Change value con filter combo box > click on Clear Filter.

  • It's fixed on the next release.

@Wolfenry
Copy link
Author

Haha ok! i will try the new release im hyped now, excelent job guys, i'll be into it!
Good luck.

@stsrki
Copy link
Collaborator

stsrki commented Feb 25, 2021

Yes, it's still planned to be released soon. If not this week it will be the beginning of the next, guaranteed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants