Skip to content

feat: add ability to set tooltip for column header to FluentDataGrid #2757

Closed

Description

@Leon99

🙋 Feature Request

I'd like to set a tooltip for a column header that is different from Title, but it seems impossible at the moment.

💁 Possible Solution

I tried to override HeaderCellItemTemplate, but generated code misses a necessary attribute:
image
That autogenerated attribute that applies the necessary styling is missing when setting HeaderCellItemTemplate as

<div class="col-title">
   <div class="col-title-text" title="@tooltip">@Title</div>
</div>

Activity

  1. added
    triage
    on Oct 4, 2024
  2. vnbaaij commented on Oct 4, 2024

    @vnbaaij
    Collaborator

    In determining what tooltip to show in the header, the following code is now used:

    string? tooltip = Tooltip ? Title : null;
    

    (in ColumnBase.razor, right above where your <div... code comes from.

    What if we change that to:

    string? tooltip = Tooltip ? (TooltipText ?? Title) : null;
    

    That way you could use the TooltipText parameter to change the tooltip text even with the standard header template.

    ps: In your HeaderCellItemTemplate, I think you should be able to get that attribute added by using ::deep in your own styles

  3. added
    needs: author feedback
    and removed
    triage
    on Oct 5, 2024
  4. added a commit that references this issue on Oct 7, 2024
    a200775
  5. vnbaaij commented on Oct 7, 2024

    @vnbaaij
    Collaborator

    Turns out we can't do it in the way I suggested. When rendering the headers, we do not have an actual item available yet that can act as the context for getting the TooltipText function executed,

  6. vnbaaij commented on Oct 7, 2024

    @vnbaaij
    Collaborator

    Creating a new PR for this. We have now solved this by adding a new HeaderTooltip parameter to the column:

    <TemplateColumn Tooltip="true" HeaderTooltip="Flag of each team" TooltipText="@(c => "Flag of " + c.Name)" Title="Rank"...
    

    image

  7. added a commit that references this issue on Oct 7, 2024
    b434574
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs: author feedback

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions