Programatically retrieve GridColumn 'HeaderText'

Is there a way of programmatically retrieving a GridColumn's "Header Text"?

(If it helps for you to know this, currently I have hard-coded the GridColumn's HeaderText; inline.)


1 Reply

PS Prathap Senthil Syncfusion Team October 11, 2024 08:07 AM UTC


Hi Rick Berger,

Based on your requirement, you want to retrieve the GridColumn HeaderText programmatically. We suggest using the method below to access the GridColumn properties, including HeaderText, through the instance of the grid's columns. Kindly refer to the code snippet and sample below for your reference.

<SfGrid @ref="grid" DataSource="@GridData" AllowPaging="true">

----

</SfGrid>

 

<Syncfusion.Blazor.Buttons.SfButton OnClick="GetHeaderText">Get Header Text</Syncfusion.Blazor.Buttons.SfButton>

 

@code {

    private SfGrid<Order> grid;

 

 

    private  async Task GetHeaderText()

    {

        var headerTexts = grid.Columns.Select(column => column.HeaderText).ToList();

      

        Console.WriteLine(string.Join(", ", headerTexts));

    }

}

 

 

 


Sample:https://blazorplayground.syncfusion.com/embed/rDrJiDiWLmnfwhMt?appbar=true&editor=true&result=true&errorlist=true&theme=bootstrap5

If you still face any difficulties with the solution, could you please share more details about your requirement and how you would like to retrieve the header text programmatically? Based on this information, we will update the solution as soon as possible.


Regards,
Prathap Senthil


Loader.
Up arrow icon