We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Context in Header Template is null

Hello,

I am trying to define context in the header template but the value is null. Is it possible to define context in header template  or it only works in <Template> 




1 Reply

MS Monisha Saravanan Syncfusion Team February 20, 2023 12:11 PM UTC

Hi  Kapil,


Greetings from Syncfusion support.


Query: “I am trying to define context in the header template but the value is null. Is it possible to define context in header template  or it only works in <Template> ”


It is not possible access corresponding row details inside header template context. We would like to inform you that using Header template context, it is possible to retrieve the corresponding column details and we can perform customization using column details. We have attached a code snippet below that should be helpful in addressing your concern.


<SfGrid ID="Grid" @ref="DefaultGrid" DataSource="@Orders" AllowPaging="true">

    <GridEvents OnToolbarClick="ToolbarClickHandler" TValue="Order"></GridEvents>

    <GridColumns>

        <GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" Width="150">

            <HeaderTemplate>

                @{

                    var a = (context as GridColumn);

                   

 

                }

            </HeaderTemplate>

        </GridColumn>

    </GridColumns>

</SfGrid>

 


If you still face difficulties then kindly get back to us with additional details about your requirement.


Loader.
Live Chat Icon For mobile
Up arrow icon